1

How to get Magento category page title in frontend? Already tried:

<?php if ($category->getPageTitle()):?>
    <?php echo $_helper->categoryAttribute($_category, $_category->getPageTitle(), 'page_title') ?>
<?php else: ?>

enter image description here

4
  • yes as suggested in mage i want to display here page title Commented Aug 5, 2016 at 9:25
  • plz show which error are display? or plz show full code Commented Aug 5, 2016 at 9:26
  • hi @Payaljhamta, may i know what kind search box you are using
    – Gem
    Commented Aug 5, 2016 at 10:32
  • You have a typo here $category, and $_category->getPageTitle(). And Page Title field would be appearing there as meta title
    – Duke
    Commented Jun 3, 2020 at 7:26

2 Answers 2

0

I think, you have a typo here (if you have created page_title attribute) :

Replace <?php if ($category->getPageTitle()):?> WITH <?php if ($_category->getPageTitle()):?>

If you want to get meta_title (this is shown as Page Title in category edit page at admin)

enter image description here

then use :

<?php if ($_category->getMetaTitle()):?>
    <?php echo $_helper->categoryAttribute($_category, $_category->getMetaTitle(), 'meta_title') ?>
<?php else: ?>
3
  • yes as suggested in mage i want to display here page title so i can add this code in head.html Commented Aug 5, 2016 at 9:26
  • updated the code/answer Commented Aug 5, 2016 at 9:26
  • these page title i want to display in frontend as i mentioned in our qustion Commented Aug 5, 2016 at 9:54
0

You need to rewrite Mage_Catalog_CategoryController

add below code in viewAction after $this->loadLayoutUpdates(); code

<?php if ($category->getMetaTitle()):?>    
       <?php $this->getLayout()->getBlock('head')->setTitle($this->__($category->getMetaTitle())); ?>
<?php else: ?>

How to rewrite controller

5
  • these page title i want to display in frontend as i mentioned in my qustion Commented Aug 5, 2016 at 10:15
  • Updated answer please check it Commented Aug 5, 2016 at 10:23
  • Please make me clear which file i have to add code Commented Aug 5, 2016 at 10:25
  • updated answer check it Commented Aug 5, 2016 at 10:34
  • Please make me clear where i have add code i.e in which file so that Page title display as per i mentioned in image that i attached in mu question plesae Commented Aug 5, 2016 at 12:11

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.