0

I need to change the categories page title if their 'Page Title' attribute did not specify. It should set to their 'Name' attribute.
If I switch back to default theme the page title is correct so I think there's something in my custom layout xml files. I added a block with customer/form_login type in my head section and there's this line of code inside its class:

File: app/code/core/Mage/Customer/Block/Form/Login.php:
protected function _prepareLayout()
{
    $this->getLayout()->getBlock('head')
         ->setTitle(Mage::helper('customer')
         ->__('Customer Login')); // <-- This sets the title
    return parent::_prepareLayout();
}

I heard everywhere on the net to comment out this line but I don't want to do this because of two reasons:

  1. It is bad and ugly even if I copy the whole file into app/code/local folder.
  2. I noticed that the default theme will set the title correctly even if I include the login form block inside its head. So it must be something inside my layout files.

Any idea would be appreciated.

2 Answers 2

1

Overwriting core code doesn't have to be an issue per sé. If you do it from you own custom extension you won't actually have to change the core files, just overwrite the method you want to change.

Check out Inchoo's article on overwriting. Basically you create your own extension in the local code pool and add a custom block

app/code/local/[Namespace]/[Module]/etc/config.xml

<config>
   <global>
   [...]
      <blocks>
         <customer>
            <rewrite>
               <form_login>[Namespace]_[Module]_Block_Customer_Form_Login</form_login>
            </rewrite>
         </customer>
      </blocks>
   [...]
   </global>
</config>

app/code/local/[Namespace]/[Module]/Block/Customer/Form/Login.php

class [Namespace]_[Module]_Block_CustomerForm_Login extends Mage_Customer_Block_Form_Login
{
    protected function _prepareLayout()
    {
        $this->getLayout()->getBlock('head')
             ->setTitle(Mage::helper('customer')->__('Customer Login'));

        return parent::_prepareLayout();
    }
}
0

I compared my catalog.xml with base catalog.xml and I noticed that I removed this block:

<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>

It seems that this block (and it's corresponding class) is responsible for setting the page title. I added this block and everything's look fine now.

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.

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