2015-03-25 91 views
0

我目前正在开发一个带有Magento的电子商务系统。我已经打电话给我的页脚 <?php echo $this->getChildHtml('footer') ?> 和我layout.xml有以下标签来定义“页脚”将脚本标记添加到magento layout.xml

<reference name="footer"> 
    <block type="page/footer" name="footer"> 
    <action method="setTemplate"> 
     <template>page/html/footer_home.phtml</template> 
    </action> 
    <action method="setTemplate"> 
     <template>muaw/footer_script.phtml</template> 
    </action> 
    </block> 
</reference> 

footer_home.phtml是实际的页脚和footer_script.phtml<script>标签对于一些jQuery的文件。我的问题是,为footer_script.phtml添加第二组<action>标记替换实际页脚。有没有其他方法来获取这两个文件?

+0

由于页脚将始终显示在网站,和u在 并将该js放入js文件夹中。 – 2015-03-25 12:15:21

+0

不错的主意。但我不认为这是最佳做法。无论如何。 – 2015-03-25 12:43:18

+0

您在'page/footer'块上调用了两次'setTemplate()'方法。这没有任何意义,因为该块只能有一个模板,而不能有两个。使用不同的参数调用该方法两次,因此会导致其中一个无用。因此,无论您尝试做什么都很明显,您已经使用了错误的工具。 – hakre 2015-03-25 13:32:18

回答

0

您不需要为页脚设置两个模板。只要你refrence文件PHTML像这样......

<reference name="footer"> 
    <block type="page/footer" name="footer"> 
     <action method="setTemplate"> 
      <template>page/html/footer_home.phtml</template> 
     </action> 
    </block> 
    <block type="core/template" name="footer_script" template="muaw/footer_script.phtml"/> 
</reference> 
0

您应该添加footer_script.phtml到

<reference name="before_body_end">