【问题标题】:Magento - How to add a widget in a variable in a static blockMagento - 如何在静态块的变量中添加小部件
【发布时间】:2015-05-27 13:55:45
【问题描述】:

大家好,这可能有点傻,我想知道是否可以将小部件添加到我制作的变量中。

{{translate fr='' en=''}}

这是变量。安静的简单管理员可以仅在 1 个静态块中翻译多种语言的静态块,这就是我所需要的。 (我不能为每种语言做多个静态块)

现在我的问题是:我该怎么做:

{{translate fr='{{widget type="catalog/category_widget_link" anchor_text="À propos" title="À propos" template="catalog/category/widget/link/link_block.phtml" id_path="category/9"}}' en='{{widget type="catalog/category_widget_link" anchor_text="About us" title="About us" template="catalog/category/widget/link/link_block.phtml" id_path="category/9"}}'}}

如您所见,我要做的是翻译小部件。但它被 {{ }} 弄糊涂了。我最终得到了这个:

{{widget type="catalog/category_widget_link" anchor_text="À propos" title="À propos" template="catalog/category/widget/link/link_block.phtml" id_path="category/9"' en='About us '}}

在视图中而不是 À 提议/关于我们。

这是translate 函数:

public function translateDirective($construction)
{

    $params = $this->_getIncludeParameters($construction[2]);
    Mage::log(print_r($params, 1), null, 'logfile.log');
    if($store_code = Mage::app()->getStore()->getCode() == 'default' || $store_code = Mage::app()->getStore()->getCode() == 'english_canada') $words = $params['en'];
    else if($store_code = Mage::app()->getStore()->getCode() == 'french') $words = $params['fr'];

    //return $words;
    return $words;

} 

任何帮助将不胜感激

提前谢谢!

【问题讨论】:

    标签: magento static-block


    【解决方案1】:

    好的,所以我找到了一个适合我的解决方法,而不是使用小部件来链接我将使用链接的类别/页面。它对用户不太友好,但我可以这样处理:

    <li><a title="{{translate en="Term & Conditions" fr="Terme & Conditions"}}" href="{{store url="customer-service"}}">{{translate en="Term &amp; Conditions" fr="Terme &amp; Conditions"}}</a></li>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-22
      • 1970-01-01
      • 1970-01-01
      • 2015-09-08
      相关资源
      最近更新 更多