【问题标题】:getTitle() on Doctrine i18n with non-default language具有非默认语言的 Doctrine i18n 上的 getTitle()
【发布时间】:2010-06-18 10:49:11
【问题描述】:

我在从 Doctrine 1.1.6 / Symfony 1.2 中的 i18n 对象获取对象标题时遇到问题

我有以下 Doctrine Table 方法:

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();

}

然后在视图文件上,如果我执行 $place->getTitle(),它会以我想要的语言正确打印标题。但是,如果我对一个操作执行 $place->getTitle() 它什么都不返回,我必须执行 $place->Translation['es']->title 以获取西班牙语标题。如果我使用默认语言 ('en') $place->getTitle() 工作。

知道如何让 $place->getTitle() 一直工作吗?

谢谢!

【问题讨论】:

    标签: doctrine internationalization


    【解决方案1】:

    我不知道为什么它不起作用;所以我现在做 $place->Translation[$lang]->title 来获得我想要的语言的标题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-18
      • 1970-01-01
      • 1970-01-01
      • 2011-05-12
      • 1970-01-01
      • 1970-01-01
      • 2011-05-03
      相关资源
      最近更新 更多