cancel
Showing results for 
Search instead for 
Did you mean: 

Create New Tabs on Front End and Back End

SOLVED

Create New Tabs on Front End and Back End

So, I would like to add on a new tab called warranty. We only sell several manufacturers, so instead of copy and pasting all the time, I would like to add it with a static block. 

 

So, I would like to have a new tab on the front end called Warranty. I would then like to drop in the static block name in the admin (heck, a drop down of all static blocks would be nice). 

 

How would I accomplish this?

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Create New Tabs on Front End and Back End

This is how I was able to do it. Thank you for your reply as it got me on the right track. 

 

This gives the input to the back end 

added attribute warranty_tab

added warranty_tab to my attribute set

 

Now to add to Front End.

/app/design/frontend/theme/deafult/layout/local.xml

 

Find Additional Info tab on local.xml. Add the code below where you want to add the tab in the sort order. 

Product Description - Additional Info - Warranty - Reviews is how I have mine.

 

<!-- Warranty tab -->
<action method="addTab" translate="title" module="catalog"><alias>warranty</alias>
<title>Warranty</title><block>catalog/product_view</block>
<template>catalog/product/view/warranty_tab.phtml</template>
 </action>

 

Create Template File

The code above, the template warranty_tab.phtml was called and it needs to br created. 

Create new file called warranty_tab.phtml. Add code below. 

 

<?php
$_product = $this->getProduct();
$attribute = $_product->getResource()->getAttribute('warranty_tab');
if ( is_object($attribute) ) {
  $identifier = $_product->getData("warranty_tab");
}
?>
 
<?php if ($_warrantyBlock = Mage::app()->getLayout()->createBlock('cms/block')->setBlockId($identifier)): ?>
    <div class="std">
        <?php echo $_warrantyBlock->toHtml() ?>
    </div>
<?php endif; ?>

drop file in /app/design/frontend/theme/default/template/catalog/product/view

 

If you do not want template changes to be overwritten when you update the theme, then in the /theme/default sections, create new folder /whatever/ and create the same folder structure. I use the name custom and you can see the structure below. 

 

/app/design/frontend/theme/custom/template/catalog/product/view

/app/design/frontend/theme/custom/layout/local.xml

 

You will have to update configuration > design > theme. Under the default at the bottom, add in custom or the name you are using in your heiarchy folder structure.

 

View solution in original post

3 REPLIES 3

Re: Create New Tabs on Front End and Back End

Very simple to achieve your needs, follow below instructions:

 

1. Create new attribute 'warranty' from BE; Menu: Catalog >> Attributes >> Manage Attributes
2. Go on menu: Catalog >> Attributes >> Manage Attribute Sets  and cerate new Group and drag newly created attribute from right end side (unassigned attributes) into that group.

 

By above things tab should be added from your BE manage proeducts. Now edit any product and go into Warrenty tab and paste your static block identifier).

 

Frontend:

1. app/design/frontend/[theme]/default/layout/catalog.xml And find below line:

 

<block type="catalog/product_view_attributes" name="product.attributes" as="additional" template="catalog/product/view/attributes.phtml">

 

Now add your own “tab” code afterwards, as below:

 

 

Spoiler
<block type="catalog/product_view_attributes" name="product.warranty" as="warranty" template="catalog/product/view/warranty.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Warranty Guide</value></action>
</block>

 

now create new file over app/design/frontend/[theme]/default/template/catalog/product/view/warrenty.phtml

And add below code

 

<?php
$_product = $this->getProduct();
$attribute = $_product->getResource()->getAttribute('warrentry');
if(is_object($attribute)){
  $identifier = $_product->getData("warrentry");
}
?>
 
<?php if ($_sizeBlock = Mage::app()->getLayout()->createBlock('cms/block')->setBlockId($identifier)): ?>
    <div class="std">
        <?php echo $_sizeBlock->toHtml() ?>
    </div>
<?php endif; ?>

And you done!  You warrenty tab should be show into FE and BE.

P.S - PM me for quick reply.

 

Hope it helps you Smiley Happy

-
Magento Programmer | Was my answer helpful? You can accept it as a solution.

Re: Create New Tabs on Front End and Back End

This is how I was able to do it. Thank you for your reply as it got me on the right track. 

 

This gives the input to the back end 

added attribute warranty_tab

added warranty_tab to my attribute set

 

Now to add to Front End.

/app/design/frontend/theme/deafult/layout/local.xml

 

Find Additional Info tab on local.xml. Add the code below where you want to add the tab in the sort order. 

Product Description - Additional Info - Warranty - Reviews is how I have mine.

 

<!-- Warranty tab -->
<action method="addTab" translate="title" module="catalog"><alias>warranty</alias>
<title>Warranty</title><block>catalog/product_view</block>
<template>catalog/product/view/warranty_tab.phtml</template>
 </action>

 

Create Template File

The code above, the template warranty_tab.phtml was called and it needs to br created. 

Create new file called warranty_tab.phtml. Add code below. 

 

<?php
$_product = $this->getProduct();
$attribute = $_product->getResource()->getAttribute('warranty_tab');
if ( is_object($attribute) ) {
  $identifier = $_product->getData("warranty_tab");
}
?>
 
<?php if ($_warrantyBlock = Mage::app()->getLayout()->createBlock('cms/block')->setBlockId($identifier)): ?>
    <div class="std">
        <?php echo $_warrantyBlock->toHtml() ?>
    </div>
<?php endif; ?>

drop file in /app/design/frontend/theme/default/template/catalog/product/view

 

If you do not want template changes to be overwritten when you update the theme, then in the /theme/default sections, create new folder /whatever/ and create the same folder structure. I use the name custom and you can see the structure below. 

 

/app/design/frontend/theme/custom/template/catalog/product/view

/app/design/frontend/theme/custom/layout/local.xml

 

You will have to update configuration > design > theme. Under the default at the bottom, add in custom or the name you are using in your heiarchy folder structure.

 

Re: Create New Tabs on Front End and Back End

Do you have any insight on how to hide the tab if you have no information for it, i.e. no warranty information?

 

Thanks.