如何在Magento中覆盖另一个文件模块的布局xml文件

时间:2016-12-01 04:48:22

标签: php xml magento layout magento-1.7

我有一个模块Askit,位于以下目录

/var/www/html/app/design/frontend/base/default/template/tm/askit/

form.phtml页面包含在以下目录中

/var/www/html/app/design/frontend/base/default/template/tm/askit/question/form.phtml

我想更新其布局xml以设置其phtml页面的元数据。

正如我所指的那样this question

http://example.com/questions/

我想从我的主题local.xml文件

为上面的页面设置meta

这里是布局xml目录url -

/var/www/html/app/design/frontend/argento/mall/layout

我在我的主题布局local.xml文件中编写了以下代码,但它没有更新此页面的元数据 -

<askit_question_index>
   <reference name="head">
      <action method="setTitle"><value>Ask an Expert and Get Answers - </value></action>
      <action method="setDescription"><value>Ask a question and get an answer to your question from a Expert related to your purchased product </value></action>
   </reference>
</askit_question_index>

1 个答案:

答案 0 :(得分:0)

根据上面提到的代码,它主要应该来自local.xml。但如果不是,您可以通过控制器添加元信息。

在调用indexAction

后,将以下代码添加到控制器QuestionController$this->loadLayout(); and $this->loadLayout();)中
$headBlock = $this->getLayout()->getBlock('head');
if ($headBlock){
    $headBlock->setTitle($this->__('Ask an Expert and Get Answers'));
    $headBlock->setDescription($this->__('Ask a question and get an answer to your question from a Expert related to your purchased product'));
    $headBlock->setKeywords($this->__('Meta keywords here'));
}