Re: Translate behavior and ordering/searching
Hi, > I had the same problem couple weeks ago. The paginationCount function > doesn't work well with i18n tabel. It gets confused on table name. > Luckily we can overwrite this function to return us a proper number of > records. It's a bit tricky I think but it works well for me. Tremendous! You saved me a night, I owe you some Polish beer :) Regards, Piotr --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Translate behavior and ordering/searching
Hi Guys, I had the same problem couple weeks ago. The paginationCount function doesn't work well with i18n tabel. It gets confused on table name. Luckily we can overwrite this function to return us a proper number of records. It's a bit tricky I think but it works well for me. 1. Put these sample functions in your model or app_model function setPaginate($method=''){ if (empty($method)){ $this->usePaginateMethod = 'standard'; }else{ $this->usePaginateMethod = $method; } } function paginateCount($conditions, $recursive, $extra){ switch ($this->usePaginateMethod) { case 'standard': return $this->standardPaginateCount($conditions, $recursive, $extra); break; case 'customized': //using same standard for now return $this->customizedPaginateCount($conditions, $recursive, $extra); break; } } function standardPaginateCount($conditions, $recursive, $extra){ $results = $this->find('count', compact('conditions', 'recursive', 'extra')); return $results; } function customizedPaginateCount($conditions, $recursive, $extra){ $results = $this->find('all', compact('conditions', 'recursive', 'extra')); $count = count($results); return $count; } 2. Apply two extra lines in controller before calling a paginate function. $this->Course->setPaginate('customized'); //specify to use customizedPaginateCountfunction $courses = $this->paginate('Course',$options['conditions']); $this->Course->setPaginate('standard'); //set back to standard one, just in case we use normal paginate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Translate behavior and ordering/searching
> Any idea how can I make for example pagination use the current locale > in a model that $actsAs Translate? OK, got through a part of it, but sadly paginator count doesn't work... What I have in find conditions is: $conditions['I18n__title.content LIKE'] = '%' . $this->data['Article']['title'] . '%'; Proper records are retrieved, but since the paginator count query uses different syntax what I end up with is: 1054: Unknown column 'I18n__title.content' in 'where clause' Query: SELECT COUNT(DISTINCT(`Article`.`id`)) AS count FROM `articles` AS `Article` INNER JOIN `i18n` AS `I18nModel` ON (`Article`.`id` = `I18nModel`.`foreign_key` AND `I18nModel`.`model` = 'Article' AND `I18nModel`.`locale` = 'eng') LEFT JOIN `article_sections` AS `ArticleSection` ON (`Article`.`article_section_id` = `ArticleSection`.`id`) LEFT JOIN `article_categories` AS `ArticleCategory` ON (`Article`.`article_category_id` = `ArticleCategory`.`id`) LEFT JOIN `statuses` AS `Status` ON (`Article`.`status_id` = `Status`.`id`) WHERE `I18n__title`.`content` LIKE '%article%' Any quick suggestions? I'll try to get through this over the weekend and get back with my ideas. Regards, Piotr --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Translate behavior and ordering/searching
Hello, Any idea how can I make for example pagination use the current locale in a model that $actsAs Translate? Any help would be great. Regards, Piotr --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---