我可以在 layout.xml 文件中获取存储配置值吗?

Can i get store configuration value in layout.xml file?

我创建了一个模块,我在管理面板中对布局进行了一些设置。

我的 layout.xml 代码(我在顶部 link 中添加了 link):

<reference name="top.links">
            <action method="addLink" translate="label title" ifconfig="mbyte/mbyte_links/map_header">
                <label>Store locator</label>
                <url>storelocator/index/index</url>
                <title>Store Locator</title>
                <prepare>true</prepare>
                <position>2</position>
        </action>

就像我在配置设置中添加了 ifconfig="mbyte/mbyte_links/map_header" 检查天气是否启用一样。

我还有一个 <title> 的配置设置。现在我的问题开始

是否可以获取我在管理面板中设置的配置值并直接在布局文件中设置,如果可以,执行此操作的过程是什么?

提前致谢!!

尝试替换为:

 <label>Store Locator</label>

有了这个:

<label helper="module/getTitle" />

此代码应调用 Custom_Module_Helper_Data::getTitle();并将其作为 <label> 参数

这对我有用。

在您的模块中创建一个助手

app/code/local/Mbyte/Links/Helper/Data.php

class Mbyte_Links_Helper_Data extends Mage_Core_Helper_Abstract
{
    public function getTitleFromConfig()
    {
        return Mage::getStoreConfig('mbyte/mbyte_links/title');
    }
}

然后在你的layout.xml中你可以使用

<reference name="top.links">
        <action method="addLink" translate="label title" ifconfig="mbyte/mbyte_links/map_header">
            <label helper="mbyte/data/getTitleFromConfig" />
            <url>storelocator/index/index</url>
            <title helper="mbyte/data/getTitleFromConfig"/>
            <prepare>true</prepare>
            <position>2</position>
    </action>