【问题标题】:GetChildHtml method returning empty string for head block- Magento 1.9GetChildHtml 方法为头块返回空字符串- Magento 1.9
【发布时间】:2020-11-26 09:59:23
【问题描述】:

我一直在尝试将现有的 magento 1.9 项目迁移到 ec2 服务器,其他所有内容以及管理面板均已正确设置,但未加载 head.phtml 并且 this->getChildHtml('head') 返回空字符串。

页面.xml

<block type="page/html" name="root" output="toHtml" template="page/1column.phtml">

        <block type="page/html_head" name="head" as="head">
            <action method="addJs"><script>prototype/prototype.js</script></action>
            <action method="addJs"><script>lib/ccard.js</script></action>
            <action method="addJs"><script>prototype/validation.js</script></action>
            <action method="addJs"><script>scriptaculous/builder.js</script></action>
            <action method="addJs"><script>scriptaculous/effects.js</script></action>
            <action method="addJs"><script>scriptaculous/dragdrop.js</script></action>
            <action method="addJs"><script>scriptaculous/controls.js</script></action>
            <action method="addJs"><script>scriptaculous/slider.js</script></action>
            <action method="addJs"><script>varien/js.js</script></action>
            <action method="addJs"><script>varien/form.js</script></action>
            <action method="addJs"><script>varien/menu.js</script></action>
            <action method="addJs"><script>mage/translate.js</script></action>
            <action method="addJs"><script>mage/cookies.js</script></action>

            <action method="addItem"><type>skin_js</type><name>js/jquery-1.12.1.min.js</name></action>
            <action method="addItem"><type>skin_js</type><name>js/jquery-migrate-1.3.0.min.js</name></action>
            <action method="addItem"><type>skin_js</type><name>js/jquery-noconflict.js</name></action>
            <action method="addItem"><type>skin_js</type><name>codazon/bootstrap/js/bootstrap.min.js</name></action>
            <!--<action method="addItem"><type>skin_js</type><name>js/snowfall.jquery.min.js</name></action>-->
            <action method="addItem"><type>skin_js</type><name>js/theme.js</name></action>
            <block type="core/template" name="cdz_custom_head" template="page/html/cdz_custom_head.phtml" />
            <block type="page/js_cookie" name="js_cookies" template="page/js/cookie.phtml"/>
            
            <action method="addItem"><type>skin_css</type><name helper="themeframework/bootstrapCssFile"/></action>
            
            <action method="addItem"><type>skin_css</type><name>css/fontawesome/font-awesome.min.css</name></action>
            <action method="addItem"><type>skin_css</type><name>codazon/bootstrap/css/bootstrap-theme.min.css</name></action>
            <action method="addCss"><stylesheet>css/styles.css</stylesheet></action>
            <action method="addCss"><stylesheet>css/responsive.css</stylesheet></action>
            <action method="addItem"><type>skin_css</type><name>css/styles-ie.css</name><params/><if>lt IE 8</if></action>
            <action method="addCss"><stylesheet>css/widgets.css</stylesheet></action>
            <action method="addCss"><stylesheet>css/print.css</stylesheet><params>media="print"</params></action>
            <action method="addItem"><type>skin_js</type><name helper="themeframework/sliderJsFile" /></action>
            <action method="addItem"><type>skin_css</type><name>codazon/owl.carousel/owl.carousel.min.css</name></action>
            <action method="addItem"><type>skin_css</type><name>codazon/owl.carousel/owl.theme.default.min.css</name></action>
            <action method="addItem"><type>skin_js</type><name>codazon/jasny-bootstrap/jasny-bootstrap.min.js</name></action>
            <action method="addItem"><type>skin_css</type><name>codazon/jasny-bootstrap/jasny-bootstrap.min.css</name></action>
            <action method="addItem"><type>skin_js</type><name>js/lib/modernizr.custom.min.js</name></action>
            <!--action method="addItem"><type>skin_js</type><name>js/lib/selectivizr.js</name></action>
            <action method="addItem"><type>skin_js</type><name>js/lib/matchMedia.js</name></action>
            <action method="addItem"><type>skin_js</type><name>js/lib/matchMedia.addListener.js</name></action-->
            <action method="addItem"><type>skin_js</type><name>js/lib/enquire.js</name></action>
            
            
            <action method="addItem"><type>skin_js</type><name>js/app.js</name></action>
            <!--action method="addItem"><type>skin_js</type><name>js/lib/jquery.cycle2.min.js</name></action>
            <action method="addItem"><type>skin_js</type><name>js/lib/jquery.cycle2.swipe.min.js</name></action>
            <action method="addItem"><type>skin_js</type><name>js/slideshow.js</name></action-->
            
            
            
            <action method="addItem"><type>js</type><name>lib/ds-sleight.js</name><params/><if>lt IE 7</if></action>
            <action method="addItem"><type>skin_js</type><name>js/ie6.js</name><params/><if>lt IE 7</if></action>
            
            <action method="addItem"><type>skin_css</type><name>css/animate.min.css</name></action>
        </block>

1column.phtml

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

正如我们在下图中看到的,head 标签没有被渲染。

谢谢。

【问题讨论】:

  • 您是否尝试将getChildHtml 更改为getBlockHtml

标签: php magento magento2 magento-1.9


【解决方案1】:

试试这个:

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

【讨论】:

    【解决方案2】:

    我通过从项目中删除 GTSPEED 模块解决了这个问题,因为它以某种方式限制了 head.phtml 正确加载。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-23
      相关资源
      最近更新 更多