getTitle() on Doctrine i18n with non-default language

Posted by fesja on Stack Overflow See other posts from Stack Overflow or by fesja
Published on 2010-06-18T10:49:11Z Indexed on 2010/06/18 10:53 UTC
Read the original article Hit count: 234

Filed under:
|

Hi,

I'm having a problem getting the title of an object from my i18n object in Doctrine 1.1.6 / Symfony 1.2

I have the following Doctrine Table method:

public function getPlace($place_id, $lang=''){
$q = Doctrine::getTable('Place')
  ->createQuery('p');

if($lang != '')
  $q = $q->leftJoin('p.Translation ptr')
    ->addWhere('ptr.lang = ?', $lang);

return $q->addWhere('p.id = ?', $place_id)
    ->fetchOne();

}

Then on the view file if I do $place->getTitle(), it prints the title correctly in the language I wanted. However, if I do $place->getTitle() on an action it returns nothing, I have to do $place->Translation['es']->title to get the title in Spanish. If I work with the default language ('en') $place->getTitle() works.

Any idea on how to make $place->getTitle() to work always?

thanks!

© Stack Overflow or respective owner

Related posts about doctrine

Related posts about i18n