donglu1971 2013-01-13 23:52
浏览 47
已采纳

k2额外字段翻译问题

i have an issue that is going to destroy my mind ... i am not a PHP developer so i can not find any way to solve it...

I am using K2 (v 2.6.2 updated from 2.5.7) for CCK (with alotof custom templates) and Joomfish (2.1.7) deployed on a Joomla 1.5.26 installation.

I was using the following code (in my templates) in order to fetch my individual k2 extra fields by name (K2 2.5.7):

$extraFld = array();
if ( $this->item->extra_fields ) {
  foreach ( $this->item->extra_fields as $key=>$extraField ) {
    $extraFld[ $extraField->name ] = $extraField->value;
   }
}

and then i was fetching it like this:

echo "<li class=\"dinning-cuisine\"><span>" . JText::_('Cuisine') . "</span><br />" . $extraFld['Cuisine'] . "</li>
";

But since version 2.6.2 there is the option to directly fetch an extra field name & val:

$this->item-extraFields->ALIASNAME->name $this->item-extraFields->ALIASNAME->value

as described in K2 2.6.2 What is new documentation.

The problem is the following:

I have a bi-lingual site in Greek (default) and English locales.

I create an extra field in Default locale "Πεδίο 1" with alias name 'field1'

If i try to translate it the only option i have is to translate its name to lets say 'Extra Field 1' (different than its alias) ...

Then in my custom template if i try to fetch it like:

$this->item->extraFields->field1->value 

only the Greek locale works. In English locale i receive a NULL value!

Any relevant experiences and solutions ?

  • 写回答

2条回答 默认 最新

  • drogon982007 2013-02-18 10:23
    关注

    After quite alot of tests i think that in a multilingual web site, retrieving individual extra field values using their alias name does not work. At least not for Joomla 1.5 ...

    The code supposed to be working is:

    $this->item-extraFields->ALIASNAME->value

    I have a web site with default language 'Greek' and secondary language 'English'.

    I have an extra field named in Greek 'Πεδίο 1' with Alias 'field1'.

    I have translated this extra field (using Joomfish) in English to 'Field 1'...

    If i try to fetch its value using:

    $this->item-extraFields->field1->value

    the code is working only for default language 'Greek' BUT NOT for English.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改
  • ¥15 Windows 系统cmd后提示“加载用户设置时遇到错误”
  • ¥50 vue router 动态路由问题
  • ¥15 关于#.net#的问题:End Function