Change any page title in Magento

Here’s a quicky one π How do you change page title of every Magento page if some titles are hardcoded into controller?
Since some controllers in Magento likes to force page titles like
$this->loadLayout();
...
$this->getLayout()->getBlock('head')->setTitle($this->__('My Account'));
$this->renderLayout();
we can’t go with setTitle through layout, since controller is setting title right before rendering.
There is a simple solution for this, use another variable for title display π
In page/html/head.phtml template replace default
with
or if you don’t wish to use title prefix/sufix added from Magento admin, simply with
and now just set “forced” title for pages through layout files
Example for My Account page in layout/customer.xml:
<customer_account>
<reference name=”head”>
<action method=”setForcedTitle”><title>Account Dashboard</title></action>
</reference>
…
</customer_account>
π
33 comments
Very helpful, thank you
A bit confused. Looking for a way to change titles and meta description in pages like “Returns”, “Advanced search”. Now it is the same as on the homepage, how do I add the ones that I need? Didn’t quite get thing with xml.
I am having a strange problem. Whenever I enter a default page title in my configuration, this title gets used for all these pages:
– Login
– Register
– Search Results
– Advanced Search
– Wishlist
– Sitemap
– Addressbook
– Applications
– Logout
– Forgot password
If I remove the default title, the correct title is being used, however some pages (Forgot Password, Logout for example) will be missing a title completely. I am aware this issue is not present on a default 1.9.2.1 installation, I am hoping somebody knows what can cause this behavior. Thanks!
How can i update meta tags in bulk througn php file?
super awesome!!!
Thank you. You made my day π
Alternatively, you can keep the
and just add this block at the top of the head.phtml page –
I love you Ivan. Nice one!
perfect!!! thanx π
Excellent! Works perfectly in 1.7 CE π
really thanks for you. another method is to use
titleTest
in your config xml file
To translate this title just add
to xml and it should looks like:
i like your post.
I want to show the price of my items in the title.
can you help me out?
Ok,but what if i want to insert in the title a filter that has been selected in the layer navigation ?
Just tried this method and it worked. However, it changed titles of all of my pages to the one I’ve typed in XML. Not complete solution π
Hey! Thanks for that! Best wishes! Tobi
This is great. However, I’m looking for a way to add the Short Description after the Product Name to the page titles on product pages. For this site, the Short Descriptions are very short and needed to differentiate similarly named products.
I’ve been looking for a solution to this problem for a day and never even thought of using another variable! Thank you!
thanks it help me a lot
What about forcing title directly from a phtml page? Im trying to get dynamic page titles working.
Hi,
This works very well for me. Thanks a lot.
However I was wondering how does the setForcedTitle function work. I could not find any equivalent function.
In which case can I use setForcedDescription for changing the meta description of a page.
Hi Inchoo!
Thanks so much for this tutorial. You saved me! π
Hi you all,
I am a fresher with Magento :), struggling finding a
way to edit the title tags and description tags in just
some pages (not products pages) but I just can’t find
them in the backend.
Please help?
Thank you guys
Hi all,
I need to change the title ONLY on product pages.
any idea?
I tried this on the Contact Form but it did not change the default title of Magento Commerce, any ideas?
thnzx a lot
Nice Tip. Here is another way to set forced title without change any file.
To set βforcedβ title for pages you can do this in the magento backend. Go to CMS/Pages and choose your page, then in the Design tab put the code in the field “Layout Update XML”. Save and refresh the cash.
Of course, first you need to do the first step in this post (change the file In page/html/head.phtml)
Regards.
Thanks a lot, exactly what I need!
It works here, thanks!
But how about changing the titles of Review pages (dynamically)?
i.e. “{Productname} Review”
Seen a couple of solutions but those didn’t work out.
I hope someone can help me out on this problem.
Thanks in advance!
Thanks….
Its working fine
Thanks …
This is very useful …
Overall this site is good … site having very useful tips & Hints ….
Keep Rokin……….
What about translation this titles?
Great Post! Thanks!
I’d like to add as a sufix, the special price in products pages only, would you have an idea for this?
Cheers