2015-11-19 116 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();?> 
相關問題