我已经在我的catalog.xml文件中添加了一个,创建了一个将用作模板的specifications.phtml文件,我正在调用echo $ this-> getChildHtml('specifications');在我的view.phtml文件中。
然而它根本没有显示任何东西。我基本上反映了产品描述相同类型的东西后面的所有东西(有效),但我没有运气。
我试图引入的内容位于产品页面下,我认为标有“规格标签”的自定义部分。不确定字段名称中的空格是否导致问题或是什么。
以下是我在view.phtml文件中的内容:
<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>
这是我添加到catalog.xml中的XML:
<!-- specifications -->
<block type="catalog/product_view_specifications" name="product.specifications.tab" as="specifications" template="catalog/product/view/specifications.phtml"/>
这是模板文件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; ?>
任何帮助将不胜感激!我对Magento或PHP不太熟悉。
谢谢,
答案 0 :(得分:0)
JUst change
<?php #echo $this->getChildHtml('specifications'); ?>
到
<?php echo $this->getChildHtml('specifications'); ?>