I searched, doesn't find a answer.

I know use layout XML to set title like below

<reference name="head">
    <action method="setTitle"><title>New Title</title></action>

But this is set title static, I need customize the title dynamically, like "shopping with (Search Phrase)", the "Search Phrase" is dynamically generate by user input. Magento has a default dynamically search page title form, I want to know the way to change its default form.

Thanks for any help!

2 Answers 2


Dynamic title provided by Block/Result.php in catalogsearch module. So you have to override the Block/Result.php into your local folder. There you can change the title as per your requirement.


Your local file path should be like this.

class Mage_CatalogSearch_Block_Result extends Mage_Core_Block_Template
     * Catalog Product collection
     * @var Mage_CatalogSearch_Model_Resource_Fulltext_Collection
    protected $_productCollection;

     * Prepare layout
     * @return Mage_CatalogSearch_Block_Result
    protected function _prepareLayout()
        // add Home breadcrumb
        $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
        if ($breadcrumbs) {
            $title = $this->__("Search results for: '%s'", $this->helper('catalogsearch')->getQueryText());

            $breadcrumbs->addCrumb('home', array(
                'label' => $this->__('Home'),
                'title' => $this->__('Go to Home Page'),
                'link'  => Mage::getBaseUrl()
            ))->addCrumb('search', array(
                'label' => $title,
                'title' => $title

        // modify page title
        $title = $this->__("shopping with ('%s')", $this->helper('catalogsearch')->getEscapedQueryText());

        return parent::_prepareLayout();
  • I have did the mentioned changes, so that the override block called as well as the core also getting called.
    – senthil
    Dec 8, 2017 at 16:22

I am not sure but you can try below code.

<?php $this->getLayout()->createBlock('page/html_head')->setTitle($title)?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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