Search code examples
xmlmagentolayouttabsblock

Add two different blocks on same tab magento


I need to add two different blocks on same tab for product description on magento, what is the best way to achieve this?

in my catalog.xml I have this:

            <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>

I need the upsell block below the description on the same tab. Thanks!

EDIT: added content of 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 ?>

Solution

  • you can call block or file using below code of particulate tab action.

    $this->getLayout()->createBlock('page/html')->setTemplate('page/html/first.phtml')->toHtml();
    
    <?php echo $this->getLayout()->createBlock('page/html')->setTemplate('page/html/second.phtml')->toHtml();