开发者

Magento attribute in title

Is there an easy way to get the value of a custom attribute to show up in the <title> on a Magento product page? I know I can add a custom title via the "Meta information / Meta Title" field. But if it's possible to automatically grab the value of an attribute and add it to the title I'd pr开发者_StackOverflow社区efer that.


You could write a module rewriting Mage_Page_Block_Html_Head#getTitle(). There, you would have to check whether you are on a product page and if yes, add the product attribute there...

A much simpler solution (although it is not as nice as the one above) would be to edit app/design/frontend/interface/theme/template/page/html/head.phtml and edit <title><?php echo $this->getTitle() ?></title>. To check whether you are on a product page, you could use:

if(Mage::registry('current_product')) {
    // add product attribute to title
}

How to get your product attribute, you can see here.

Hope this helps..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜