Thursday, October 6, 2011

Problems with HABTM Pagnitaion and i18n

Hello all,

i need help.
I had a brand model with $hasAndBelongsToMany = array('Category');
Category is a model with the translation on the field 'name'

Now depending on a category filter in a searchbox I want to identify
which brands are in the search area and which other catgeories are
assigned to these brands.

Exmaple
Search = mp3
--> Brand: apple --> Categories: smartphone, desktop computer, server,
software, mp3

I found a lot of discussions and pages and come to the solution to
%str = array(1,2,3,6); // Example
$this->Brand->recursive = 1;
$this->Brand->bindModel(array('hasOne' => array('BrandCategory')),
false);
$this->Brand->BrandCategory->locale = $this->read_language();
$options = array('fields'
=>array('Brand.id','Brand.company','Brand.url'),'contain'=>array('BrandCategory.Category.name'),'group'
=> 'Brand.id','conditions' => array('BrandCategory.category_id' =>
$str));
$this->paginate = $options;
$test2 = $this->paginate();
$this->set('brands',$test2);

The problem now is, that the Category.name is not in the required
language.

Can somebody help me ?

THANKS Jörg

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: