2

I want to generate dynamic meta title categories, based on category level.

In view.phtml category this is my code:

<?php
    $category = Mage::getSingleton('catalog/layer')->getCurrentCategory()->getParentCategory()->getTopCategory();
    $level = $this->getCurrentCategory()->getParentCategory()->getLevel();
    $curCatName = $this->getCurrentCategory()->getName();
    $halaman = "Halaman ".Mage::getBlockSingleton('page/html_pager')->getCurrentPage();
    $suffix = Mage::getStoreConfig('design/head/title_suffix');
    $newMetaTitle = "";
    if($level == 1){
        $newMetaTitle = "Sell"." "."any"." ".$curCatName." ".$suffix;
    }
    if($level == 2){
        $newMetaTitle = "Sell"." ".$curCatName." "."more items"." | ".$halaman." | ".$this->getCurrentCategory()->getParentCategory()->getName()." ".$suffix;
    }
    if($level == 3){
        $newMetaTitle = "Sell"." ".$curCatName." "."more items"." | ".$halaman." | ".$this->getCurrentCategory()->getParentCategory()->getName()." ".$suffix;
    }

    echo $newMetaTitle;
    ?>

The question is: I want to pass $newMetaTitle into head.ptml. How to do that?

0

Your Answer

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

Browse other questions tagged or ask your own question.