I have added a new tab to my product page next to my description for PDF documents. I implemented this in the local.xml using

 <action method="addTab" translate="title" module="catalog">
      <title>Data Sheets</title>

however i want to change the title depending on what category the product is in for example if you are in the clothing category (id:145) i want the Title to be "Sizing Guide" instead of "Data Sheets".

I have put an if statement in my pdf.phtml to display the sizing guide instead of the PDFs however i do not know how to change the Title. Is there any way to do this in either local.xml or to get it to get the title from pdf.phtml?

This is the code in my pdf.phtml

<?php $layer = Mage::getSingleton('catalog/layer');
$_category = $layer->getCurrentCategory();
$currentCategoryId= $_category->getId();?>
<?php $_pdf = $this->getProduct()->getPdf(); ?>

<?php if ($currentCategoryId = '145')
{?> Size table code goes here } 


<?php if ($_pdf): ?>
    <h2><?php echo $this->__('PDF') ?></h2>
    <div class="std">
        <?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_pdf, 'pdf') ?>
        <?php var_dump ($currentCategoryId);?>
<?php else: ?>
    Sorry but there are no data sheets associated with this product!
    <?php var_dump ($currentCategoryId);?>
<?php endif; 

summary: Is it possible to change the title of my tab depending on the category ID, either in the local.xml or the .phtml file it displays?

1 Answer 1


the action tag in the layouts allow you to retrieve the parameters via a helper method.
Change your layout to look like this:

<action method="addTab" translate="title" module="catalog" >    
    <title helper="[module]/getTabName" />

Now you have to create a method called getTabName in one of the helpers of one of your modules (and replace [module] with the helper alias).

the method can look like this:

public function getTabName()
    $product = Mage::registry('product'); //get the current product
    $categoryIds = $product->getCategoryIds(); //get all the category ids associated to the product.
    //based on your custom logic that involves a category id you need to return a title
    if (some condition here) {
        return 'Your tab name here'; 
    //if the product does not belong to a special category, return a default value
    return $this->__('Data Sheets');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.