我想在System> Config> Design> Header内的Header块中添加一个文本框,这是下图中的位置。
我知道这必须在xml中完成,但我不知道在哪里。我将如何在phtml文件中显示它?
答案 0 :(得分:1)
在code/core/Mage/Page/etc/system.xml
中,您将找到Magento读取以显示这些字段的配置,例如" Small Logo Image src"是一个名为logo_src_small
的字段。需要的是一个告诉Magento的模块:
标题下管理面板中的额外字段。
<config>
<sections>
<design>
<groups>
<header>
<fields>
<new_field translate="label">
<label>New Field</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</new_field>
</fields>
</header>
</groups>
</design>
</section>
</config>
重写块类code/core/Mage/Page/Block/Html/Header.php
,以便添加将公开新字段的方法。
$this->getNewField()
,其中getNewField()是您在课程中拥有的方法在第2点被覆盖。可帮助您入手的几个链接:
答案 1 :(得分:0)
首先在system.xml文件中添加一个位于
的字段app / code / core / Mage / Page / etc / system.xml,在标题部分
下<header translate="label">
..........
<welcome_massage translate="label">
<label>Welcome Massage</label>
<frontend_type>text</frontend_type>
<sort_order>35</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</welcome_massage>
</fields>
</header>
然后在标题栏中添加一个方法,app / code / core / Mage / Page / Block / Html / Header.php
public function getWelcomeMassage()
{
return $this->_data['welcome_massage'] = Mage::getStoreConfig('design/header/welcome_massage') ;
}
最后在header.phtml文件中调用此方法,就像那样
<?php echo $this->getWelcomeMassage() ?>
注意:您看到我在核心文件中有代码。你应该改写 核心文件。