[英]Setting the page title, meta description and keywords from the Block / phtml template in magento widget
我为制造商创建了一个动态着陆页小部件,然后该小部件将创建一个具有类别链接的动态着陆页,仅显示具有该制造商产品的类别。
作为此过程的一部分,我正在尝试使用此代码设置页面标题
protected function _toHtml()
{
......(build the page logic and stuff)
$head = $this->getLayout()->getBlock('head');
$head->setTitle($title);
$head->setKeywords($keywords);
$head->setDescription($description);
}
但是由于某种原因,它什么都不做,因为标题是由page / cms page-调用小部件的块设置的。
任何想法如何做到这一点?
到块的_toHtml()
被调用时,标头已经被渲染,因此设置其title变量不会产生重大影响。 您需要使用更早执行的方法,例如_prepareLayout()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.