2015-11-19 118 views
0

我试图将产品属性表放在我的产品页面上的div中,单独从通常的旁系标签的内容中放置。 我已经离我attributes.phtml的代码,我已经试过把刚才复制和将此代码粘贴到我的view.phtml的适当部分,从而产生以下:在产品页面(目录/产品/ view.phtml)中输出产品属性表

<div class="spec-table">  
<?php if($_additional = $this->getAdditionalData()): ?> 
<table class="data-table" id="product-attribute-specs-table"> 
    <col width="25%" /> 
    <col /> 
    <tbody> 
    <?php foreach ($_additional as $_data): ?> 
     <?php $_attribute = $_product->getResource()->getAttribute($_data['code']); 
     if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?> 
      <tr> 
       <th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th> 
       <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td> 
      </tr> 
     <?php } ?> 
    <?php endforeach; ?> 
    </tbody> 
</table> 
<script type="text/javascript">decorateTable('product-attribute-specs-table')</script> 

<?php endif;?> 
</div> 

当这没”牛逼的工作,我想利用我的view.phtml内调用attributes.phtml:

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('catalog/product/view/attributes.phtml')->toHtml();?> 

但可悲的是,这些方法都不似乎工作,我刚刚结束了一个空白格。 什么是最好的方式注入我的attributes.phtml(或为此,任何给定的.phtml文件的内容)在我的产品页面在任意点?

回答

0

设法利用这个工作如下

<?php echo $this->getLayout()->createBlock('catalog/product_view_attributes')->setTemplate('catalog/product/view/attributes.phtml')->toHtml();?> 
相关问题