困惑于在我的新模块中添加布局更新 [英] confused about adding a layout update in my new module
问题描述
我需要在成功页面的head标签上呈现一个特殊的脚本.
I need a special script to be rendered on the head tag on the success page.
我创建了这个文件 luisvalenciaaffiliatecj.xml 路径:/app/design/frontend/base/default/layout/luisvalenciaaffiliatecj.xml
I created this file luisvalenciaaffiliatecj.xml path: /app/design/frontend/base/default/layout/luisvalenciaaffiliatecj.xml
<?xml version="1.0"?>
<layout version="0.0.1">
<checkout_onepage_success>
<reference name="head">
<block type="core/template" name="cj_udo" template="cj/udo.phtml" />
</reference>
</checkout_onepage_success>
</layout>
我的config.xml(请参阅布局更新部分)
My config.xml (see layout updates section)
这是社区下的文件夹结构 http://screencast.com/t/WGEobN5ocjJE
this is the folder structure under community http://screencast.com/t/WGEobN5ocjJE
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Luisvalencia_Affiliate>
<version>0.0.1</version>
</Luisvalencia_Affiliate>
</modules>
<layout>
<updates>
<luisvalencia_affiliate>
<file>luisvalenciaaffiliate.xml</file>
</luisvalencia_affiliate>
</updates>
</layout>
<global>
<models>
<luisvalencia_affiliate>
<class>Luisvalencia_Affiliate_Model</class>
</luisvalencia_affiliate>
</models>
<helpers>
<affiliate>
<class>Luisvalencia_Affiliate_Helper</class>
</affiliate>
</helpers>
</global>
<frontend>
<events>
<controller_action_predispatch>
<observers>
<luisvalencia_affiliate>
<class>luisvalencia_affiliate/observer</class>
<method>captureReferral</method>
<type>singleton</type>
</luisvalencia_affiliate>
</observers>
</controller_action_predispatch>
</events>
</frontend>
</config>
我在日志上没有看到任何错误,但是由于我看不到应该在head标签上呈现的标签,因此代码未在执行.
I dont see any errors on the logs, but the code is not being executed because I cant see the tag that I should render on the head tag.
推荐答案
< layout>部分应位于< frontend>下.因此,您的config.xml应该如下所示:
<layout> section should be under <frontend>. So your config.xml should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Luisvalencia_Affiliate>
<version>0.0.1</version>
</Luisvalencia_Affiliate>
</modules>
<global>
<models>
<luisvalencia_affiliate>
<class>Luisvalencia_Affiliate_Model</class>
</luisvalencia_affiliate>
</models>
<helpers>
<affiliate>
<class>Luisvalencia_Affiliate_Helper</class>
</affiliate>
</helpers>
</global>
<frontend>
<layout>
<updates>
<luisvalencia_affiliate>
<file>luisvalenciaaffiliate.xml</file>
</luisvalencia_affiliate>
</updates>
</layout>
<events>
<controller_action_predispatch>
<observers>
<luisvalencia_affiliate>
<class>luisvalencia_affiliate/observer</class>
<method>captureReferral</method>
<type>singleton</type>
</luisvalencia_affiliate>
</observers>
</controller_action_predispatch>
</events>
</frontend>
</config>
将此代码添加到head.phtml
Add this code in echo $this->getChildHtml('cj_udo');
in head.phtml
这篇关于困惑于在我的新模块中添加布局更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!