2

我需要在同一选项卡上为 magento 上的产品描述添加两个不同的块,实现此目的的最佳方法是什么?

在我的 catalog.xml 我有这个:

            <block type="catalog/product_view_tabs" name="product.info.tabs" as="info_tabs" template="catalog/product/view/tabs.phtml" >
                <action method="addTab" translate="title" module="catalog"><alias>description</alias><title>Product Description</title><block>catalog/product_view_description</block><template>catalog/product/view/description.phtml</template></action>
                <action method="addTab" translate="title" module="catalog"><alias>upsell_products</alias><title>We Also Recommend</title><block>catalog/product_list_upsell</block><template>catalog/product/list/upsell.phtml</template></action>
                <action method="addTab" translate="title" module="catalog"><alias>additional</alias><title>Additional Information</title><block>catalog/product_view_attributes</block><template>catalog/product/view/attributes.phtml</template></action>
            </block>

我需要同一选项卡上描述下方的追加销售块。谢谢!

编辑:添加 upsell.phtml 的内容

<?php if(count($this->getItemCollection()->getItems())): ?>
<div class="box-collateral box-up-sell">
    <h2><?php echo $this->__('You may also be interested in the following product(s)') ?></h2>
    <table class="mini-products-grid" id="upsell-product-table">
    <?php // $this->setColumnCount(5); // uncomment this line if you want to have another number of columns. also can be changed in layout ?>
    <?php $this->resetItemsIterator() ?>
    <?php for($_i=0;$_i<$this->getRowCount();$_i++): ?>
        <tr>
        <?php for($_j=0;$_j<$this->getColumnCount();$_j++): ?>
            <?php if($_link=$this->getIterableItem()): ?>
            <td>
                <a href="<?php echo $_link->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_link->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_link, 'small_image')->resize(125) ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($_link->getName()) ?>" /></a>
                <h3 class="product-name"><a href="<?php echo $_link->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_link->getName()) ?>"><?php echo $this->htmlEscape($_link->getName()) ?></a></h3>
                <?php echo $this->getPriceHtml($_link, true, '-upsell') ?>
                <?php echo $this->getReviewsSummaryHtml($_link) ?>
            </td>
            <?php else: ?>
            <td class="empty">&nbsp;</td>
            <?php endif; ?>
        <?php endfor; ?>
        </tr>
    <?php endfor; ?>
    </table>
    <script type="text/javascript">decorateTable('upsell-product-table')</script>
</div>
<?php endif ?>
4

3 回答 3

1

您可以使用下面的特定选项卡操作代码调用块或文件。

$this->getLayout()->createBlock('page/html')->setTemplate('page/html/first.phtml')->toHtml();

<?php echo $this->getLayout()->createBlock('page/html')->setTemplate('page/html/second.phtml')->toHtml();
于 2013-02-26T06:14:02.080 回答
0

采用<block type="whatever" before="name_of_the_block_it_should_prepend">

当然要调整参数

于 2013-02-26T00:23:41.517 回答
0

在您的布局文件(例如:)中catalog.xml,使用parent块关键字,如下所示:

<action method="addTab" translate="title" module="catalog">
    <alias> pet_lovers_list </alias>
    <title>Pet Lovers</title>
    <block>meetai/petlovers_list</block>
    <template>meetai/petlovers/view/list.phtml</template>
</action>
<block type="meetai_comment/form" parent="pet_lovers_list" name="meetai_comment_form" as="comment_form">
    <block type="page/html_wrapper" name="pet_lover.comment.form.fields.before" as="pl_form_fields_before" translate="label">
        <label>Comments Form Fields Before</label>
        <action method="setMayBeInvisible"><value>1</value></action>
    </block>
</block>
于 2014-05-21T14:30:40.917 回答