gpt4 book ai didi

magento - 如何在关闭magento中的body标签之前调用css

转载 作者:行者123 更新时间:2023-12-02 03:22:12 25 4
gpt4 key购买 nike

在每次关闭 magento 中的 body 标签之前调用 css 会显示错误,我在 body 标签关闭之前添加了所有 js 但是当我尝试添加 css 时会显示错误?

1st method=> js and css not working and showing error

local.xml       
<reference name="before_body_end">
<block type="core/template" name="footer_js" template="footer/js.phtml">
<action method="additem"><type>skin_css</type><name>css/abc.css</name></action>
<action method="additem"> <type>skin_js</type> <name>js/share_button.js</name></action
</block>
</reference>


footer/js.phtml

<?php echo $this->getCssJsHtml() ?>

2col.phtml=> before closing body tag

<?php echo $this->getChildHtml('footer_js') ?>

2nd method js working bt css not, no error

local.xml

<reference name="before_body_end">
<block type="core/template" name="footer_js" template="footer/js.phtml"/>
</reference>

footer/js.phtml
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/jquery-1.11.1.min.js') ?>"></script>

<link href="<?php echo $this->getSkinUrl('css/negi.css')?>" rel="stylesheet" type="text/css"/>

2col.phtml=> before closing body tag

<?php echo $this->getChildHtml('footer_js') ?>

最佳答案

local.xml

<reference name="before_body_end">
<!-- add another block of type page/html_head to have all the great functionality to add/remove css and js stuff -->
<!-- it is important to set your own template, because the head block has a defined default template page/head.phtml which has all the stuff of the head. Using this will bring a lot of problems -->
<block type="page/html_head" name="abc" template="footer/abc.phtml">
<!-- add whatever you want as you are used to in the head via the standard magento api -->
<action method="addItem"><type>skin_css</type><name>css/negi.css</name></action>
</block>
</reference>

Yourtheme/template/footer/abc.phtml

<?php echo $this->getCssJsHtml() ?>
<?php echo $this->getChildHtml() ?>

2col.phtml=> 关闭 body 标签之前

<?php echo $this->getChildHtml('abc') ?>

关于magento - 如何在关闭magento中的body标签之前调用css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32607422/

25 4 0