在相同的选项卡magento上添加两个不同的块

时间:2013-02-25 21:11:28

标签: xml magento layout tabs block

我需要在同一个标​​签上添加两个不同的块,以便在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 ?>

3 个答案:

答案 0 :(得分: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();

答案 1 :(得分:0)

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

当然你必须调整参数

答案 2 :(得分: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>