duanmaifu3428 2014-04-11 13:31
浏览 42

使用getChildHtml显示无效的产品属性

I have added a to my catalog.xml file, created a specifications.phtml file to be used as the template, and I’m calling echo $this->getChildHtml(’specifications’); in my view.phtml file.

However it’s not displaying anything at all. I’ve basically mirrored everything after the same type of thing for the product description (which works) but I’m not having any luck.

The content that I’m trying to pull in is under the product page and I think a custom section that is labeled “Specifications Tab”. Not sure if the space in the field name is causing issues or what.

Here is what I have in my view.phtml file:

<div id="product-tabs" class="tabs">

    <ul class="tabs-nav">
        <li><a href="#tab-description"><?php echo $this->__('Description'); ?></a></li>

        <?php
        $specificationsTabContent = $_product->getSpecificationsTab(); 
        $videoTabContent = $_product->getVideoTab();
        $faqTabContent = $_product->getFaqTab();
        $howitworksTabContent = $_product->getHowitworksTab();
        $awardsTabContent = $_product->getAwardsTab();

        ?>

        <?php #if ($this->getChildHtml('specifications_tab')): #($this->getChildHtml('product_attributes')): ?>
        <?php if (!empty($specificationsTabContent)) : ?>
        <li><a href="#tab-details"><?php echo $this->__('Specs'); ?></a></li>
        <?php endif; ?>

        <?php if (!empty($videoTabContent)) : ?>
        <li><a href="#tab-video"><?php echo $this->__('Videos14'); ?></a></li>
        <?php endif; ?>

        <?php if (!empty($faqTabContent)) : ?>
        <li><a href="#tab-faq"><?php echo $this->__('FAQs'); ?></a></li>
        <?php endif; ?>

        <?php if (!empty($howitworksTabContent)) : ?>
        <li><a href="#tab-howitworks"><?php echo $this->__('How It Works'); ?></a></li>
        <?php endif; ?>

        <?php if (!empty($awardsTabContent)) : ?>
        <li><a href="#tab-awards"><?php echo $this->__('Awards'); ?></a></li>
        <?php endif; ?>

        <!-- <li><a href="#tab-tags"><?php #echo $this->__('Tags'); ?></a></li> -->

        <?php if ($this->getChildHtml('snippet_product_view_tab_1')): ?>
            <li><a href="#tab-custom-1"><?php echo $this->__('Custom 1'); ?></a></li>
        <?php endif; ?>

        <?php if ($this->getChildHtml('snippet_product_view_tab_2')): ?>
            <li><a href="#tab-custom-2"><?php echo $this->__('Custom 2'); ?></a></li>
        <?php endif; ?>
    </ul>

    <div class="tabs-content">

        <div id="tab-description">
            <?php echo $this->getChildHtml('description'); ?>
        </div>

        <div id="tab-details">
            <?php #echo $this->getChildHtml('specifications'); ?>
            <?php echo $specificationsTabContent; ?>
        </div>

        <div id="tab-faq">
            <?php echo $faqTabContent; ?>
        </div>

        <div id="tab-video">
            <?php echo $videoTabContent; ?>
        </div>

        <div id="tab-howitworks">
            <?php echo $howitworksTabContent; ?>
        </div>

        <div id="tab-awards">
            <?php echo $awardsTabContent; ?>
        </div>

        <!-- <div id="tab-tags">
            <?php echo $this->getChildHtml('product_additional_data') ?>
        </div> -->

        <?php if ( $this->getChildHtml('snippet_product_view_tab_1') ): ?>
        <div id="tab-custom-1">
            <div class="snippet snippet-product-view-tab-1"><?php echo $this->getChildHtml('snippet_product_view_tab_1') ?></div>
        </div>
        <?php endif; ?>

        <?php if ( $this->getChildHtml('snippet_product_view_tab_2') ): ?>
        <div id="tab-custom-2">
            <div class="snippet snippet-product-view-tab-2"><?php echo $this->getChildHtml('snippet_product_view_tab_2') ?></div>
        </div>
        <?php endif; ?>
    </div>

  </div>

This is the XML I added to my catalog.xml:

            <!-- specifications -->
            <block type="catalog/product_view_specifications" name="product.specifications.tab" as="specifications" template="catalog/product/view/specifications.phtml"/>

And this is the template file specifications.phtml:

<?php $_specifications = $this->getProduct()->getSpecificationsTab(); ?>

<?php if ($_specifications): ?>
    <h2><?php echo $this->__('Specifications') ?></h2>

    <div class="long-description std">
        <?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_specifications, 'specifications') ?>
    </div>
<?php endif; ?>

Any help would be greatly appreciated! I’m not overly familiar with Magento or PHP.

Thanks,

  • 写回答

1条回答 默认 最新

  • douxu5845 2014-04-11 16:51
    关注

    JUst change
    <?php #echo $this->getChildHtml('specifications'); ?>

    to

     <?php echo $this->getChildHtml('specifications'); ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 vue3加ant-design-vue无法渲染出页面
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序