I created a dynamic landing page widget for manufacturers, where the widget would then create a dynamic landing page with links to categories, showing only the categories that are that have products by that manufacturer.
As part of this, I am trying to set the page title using this code
protected function _toHtml()
{
......(build the page logic and stuff)
$head = $this->getLayout()->getBlock('head');
$head->setTitle($title);
$head->setKeywords($keywords);
$head->setDescription($description);
}
But for some reason this doesn't do anything, as the title is set by the page / cms page - block that calls the widget.
Any ideas how to do this?
By the time your block's _toHtml()
is called the header has already been rendered so setting it's title variable has no significant effect. You need to use a method that is executed earlier, like _prepareLayout()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.