Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 9
Adding New Product Tabs on Modern Theme
 
Voot
Sr. Member
 
Total Posts:  261
Joined:  2008-03-20
Long Beach, CA
 

I’ve searched and searched and searched and couldn’t find anything. Does anyone know how to create a new product tab? I’m creating a new attribute called “Sizing Chart” and I want to stick that info into a new product tab called “Sizing Chart”. Your help is appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Voot
Sr. Member
 
Total Posts:  261
Joined:  2008-03-20
Long Beach, CA
 

Bump! Anyone please?

 
Magento Community Magento Community
Magento Community
Magento Community
 
lotusseedsD
Mentor
 
Avatar
Total Posts:  1144
Joined:  2007-08-31
 

Can’t help you with this but I can give you a pointer as I just took a look at the tabs file this morning.

Thought JS is used, The tabs in the Modern theme isn’t called via DOM or Ajax but xml ( I maybe mistaken). Go to the ‘catalog.xml’ file, in the ‘Product view’ section , look for

<block type="catalog/product_view_tabs" name="product.info.tabs" as="info_tabs" template="catalog/product/view/tabs.phtml" >

You will see ‘ <action method="addTab" ...’, so I believe you should add a new action method, something like this:

<action method="addTab" translate="title" module="catalog"><alias>sizingchart</alias><title>Sizing Chart</title><block>catalog/product_view_charts</block><template>catalog/product/view/charts.phtml</template></action>

then you create a new ‘charts.phtml’ and place it in the ‘view folder’

If you go look at the tabs.html, you will see that it looks for tab alias.

How do you call the data for your charts this part I don’t know.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Voot
Sr. Member
 
Total Posts:  261
Joined:  2008-03-20
Long Beach, CA
 

Thanks for the reply as always chinesedream, Thats exactly where I’m stuck. The tab shows on every product page but I cant figure out how to show the content of the custom attribute. I set the attribute as a textfield type. Anyone else tried doing this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
oakRunk
Sr. Member
 
Total Posts:  117
Joined:  2008-09-15
 

Any luck with this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
weckl
Member
 
Total Posts:  50
Joined:  2008-07-13
Singapore
 

Hey Vutha,

Here goes..

Let’s say I have a custom attribute in my case would be ‘Ingredients’.

I want to display Ingredients as an additional tab in the product view page in Modern theme

so firstly, , I would add tab in 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>additional</alias><title>Additional Information</title><block>catalog/product_view_attributes</block><template>catalog/product/view/attributes.phtml</template></action>
 
                     <
action method="addTab" translate="title" module="catalog"><alias>ingredients</alias><title>Ingredients</title><block>catalog/product_view_ingredients</block><template>catalog/product/view/ingredients.phtml</template></action>
 

                                        <
action method="addTab" translate="title" module="catalog"><alias>review</alias><title>Reviews</title><block>review/product_view_list</block><template>review/product/view/list.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>

 
                </
block>

Then , I would create a phtml under /app/design/frontend/default/modern/template/catalog/product/view/ingredients/phtml

?>
<div class="product-specs">
<?php echo nl2br($this->getProduct()->getIngredients()) ?>
</div>

Now, most imporntantly, you have to create a block under /app/code /core/Mage/Catalog/Block/Product/View/Ingredients.php

class Mage_Catalog_Block_Product_View_Ingredients extends Mage_Core_Block_Template
{
    
protected $_product null;

    function 
getProduct()
    
{
        
if (!$this->_product{
            $this
->_product Mage::registry('product');
        
}
        
return $this->_product;
    
}
}

Now you should be able to see the new tab ..

see my example attached

Image Attachments
Picture 2.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
sktung
Jr. Member
 
Total Posts:  15
Joined:  2008-09-25
 

Thanks weckl!

It worked really well, but the only problem I have now is that if I create a new tab, the information in that tab still shows up under the “Additional Information” tab.

I’m pretty sure that the key file is Attributes.php which appears to build the array to populate this particular tab. However, my PHP is horrible and I am not sure how to use the ? $excludeAttr ? to exclude this information from appearing twice.

As a crude hack, I am able to accomplish this by changing the attribute to not be visible through Magento Admin but I do not believe this is the ideal solution.

also, for those who do not want the tab to appear if there is no data, just use the following code:

<?php if(count($this->getProduct()->getIngredients())): ?>
<div class="product-specs">
<?php echo $this->getProduct()->getIngredients() ?>
</div>
<?php endif ?>

Any advice would be greatly appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Charles
Member
 
Avatar
Total Posts:  73
Joined:  2008-03-27
Belgium
 

Two options:
1) either you completely discard the additional information and you comment the tab out in catalog.xml
2) you go to the attributes.phtml file to discard the info you don’t want to be displayed. Create an if statement around

<tr>
        <
td class="label"><?php echo $this->__($_data['label']?></td>
        <
td class="data"><?php echo $_helper->productAttribute($_product$_data['value']$_data['code']?></td>
    </
tr>

Gr,
Charles

 
Magento Community Magento Community
Magento Community
Magento Community
 
altapower
Jr. Member
 
Total Posts:  6
Joined:  2009-01-08
 

New kid on the block here to Magento.

I tried the instructions above and am now getting the following error.

class Mage_Catalog_Block_Product_View_Included extends Mage_Core_Block_Template { protected $_product = null; function getProduct() { if (!$this->_product) { $this->_product = Mage::registry(’product’); } return $this->_product; } } class Mage_Catalog_Block_Product_View_Included extends Mage_Core_Block_Template { protected $_product = null; function getProduct() { if (!$this->_product) { $this->_product = Mage::registry(’product’); } return $this->_product; } }
Fatal error: Class ‘Mage_Catalog_Block_Product_View_Included’ not found in /home/enertcom/public_html/app/code/core/Mage/Core/Model/Layout.php on line 461

And ideas? Thanks so much in advance.

 
Magento Community Magento Community
Magento Community
Magento Community
 
altapower
Jr. Member
 
Total Posts:  6
Joined:  2009-01-08
 

More info on this issue, any help is greatly appreciated.

Catalog.xml:

<action method="addTab" translate="title" module="catalog"><alias>included</alias><title>What's Included</title><block>catalog/product_view_included</block><template>catalog/product/view/Included.phtml</template></action>

Included.phtml /app/design/frontend/default/modern/template/catalog/product/view/ingredients/phtml

?>
<div class="product-specs">
<?php echo nl2br($this->getProduct()->getIncluded()) ?>
</div>

Inluded.php (block) /app/code /core/Mage/Catalog/Block/Product/View/Ingredients.php

class Mage_Catalog_Block_Product_View_Included extends Mage_Core_Block_Template
{
    
protected $_product null;

    function 
getProduct()
    
{
        
if (!$this->_product{
            $this
->_product Mage::registry('product');
        
}
        
return $this->_product;
    
}
}

Gives me this error:

class Mage_Catalog_Block_Product_View_Included extends Mage_Core_Block_Template { protected $_product = null; function getProduct() { if (!$this->_product) { $this->_product = Mage::registry(’product’); } return $this->_product; } } class Mage_Catalog_Block_Product_View_Included extends Mage_Core_Block_Template { protected $_product = null; function getProduct() { if (!$this->_product) { $this->_product = Mage::registry(’product’); } return $this->_product; } }
Fatal error: Class ‘Mage_Catalog_Block_Product_View_Included’ not found in /home/enertcom/public_html/app/code/core/Mage/Core/Model/Layout.php on line 461

 
Magento Community Magento Community
Magento Community
Magento Community
 
ionaudiovisual
Jr. Member
 
Avatar
Total Posts:  18
Joined:  2007-12-24
 

Im getting the same error, please can someone help.

Thanks

class Mage_Catalog_Block_Product_View_Included extends Mage_Core_Block_Template { protected $_product = null; function getProduct() { if (!$this->_product) { $this->_product = Mage::registry(’product’); } return $this->_product; } } class Mage_Catalog_Block_Product_View_Included extends Mage_Core_Block_Template { protected $_product = null; function getProduct() { if (!$this->_product) { $this->_product = Mage::registry(’product’); } return $this->_product; } }
Fatal error: Class ‘Mage_Catalog_Block_Product_View_Included’ not found in /home/enertcom/public_html/app/code/core/Mage/Core/Model/Layout.php on line 461

 
Magento Community Magento Community
Magento Community
Magento Community
 
zethris
Member
 
Total Posts:  40
Joined:  2009-01-26
 

I do not get this error after following these steps. However no tabs show up due, in part I believe, to not having any content to instert in the tabbed area. How do i now add content assuming these steps worked? Lets say for example I want to have a gallery of 4 or 5 videos pertaining to the particular product I am viewing under a “Videos” tab where a thumbnail of the videos would be clickable to have a lightbox open the video and play it?

Or something of the sort so that I can figure out the rest.

Right now, none of the new tabs show up because there is no content for it and I am unsure exactly where to now add content or how to put it into the administration screen so I can edit it’s html like, for example, the description.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ionaudiovisual
Jr. Member
 
Avatar
Total Posts:  18
Joined:  2007-12-24
 

Finally got the new tab to work. Now the issue is that even if the attribute is an empty text field the tab still shows up. I tried couple of changes in the tabs.phtml file but not working changes are :

<ul class="tabs">
    
<?php foreach ($this->getTabs() as $_index => $_tab): ?>
        <?php 
if($this->getChildHtml($_tab['alias']) != NULL || $this->getChildHtml($_tab['alias']) != '' ): ?>
        <?php 
if($this->getChildHtml($_tab['alias'])): ?>
            
<li id="product_tabs_<?php echo $_tab['alias'] ?>" <?php echo !$_index 'class="active first"' '' ?>><a href="#"><?php echo $_tab['title']?></a></li>
        
<?php endif; ?>
        <?php 
endif; ?>
    <?php 
endforeach; ?>
</ul>
<
div class="padder">
....................................

Any suggestions on where im going wrong?

 
Magento Community Magento Community
Magento Community
Magento Community
 
BloodMap
Jr. Member
 
Total Posts:  2
Joined:  2009-02-02
 

.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Charles
Member
 
Avatar
Total Posts:  73
Joined:  2008-03-27
Belgium
 

All,

that’s because the tabs are drawn independently of the content of the tabs (in tabs.php).

I’m trying to figure it for myself but it’s a tough nut to crack.
My best guess at this stage is to include a class into the tab style which sets the tab to invisible.
When the tab gets filled by content, then it’s set to display.
I’m not sure if it’s the best option but I don’t have any other trick on my sleeve.

Gr,

Charles

 
Magento Community Magento Community
Magento Community
Magento Community
 
vij
Sr. Member
 
Total Posts:  81
Joined:  2009-02-13
 

hi weckl thanks for your help it working for me the new tab..............

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 9