Continuing previous question.
- I successfully retrieved a URL of the next catalog page from catalog pager block (
Mage_Page_Block_Html_Pager). - Now I'm trying to add this URL to the head block (e.g.
<link rel="next" url="url-to-next-page" />).
-
public function core_block_abstract_to_html_before(Varien_Event_Observer $observer) {
$block = $observer->getBlock();
// Check if current block is pager block
if($block instanceof Mage_Page_Block_Html_Pager) {
// I'm getting head block
$head_block = $Mage::app()->getLayout()->getBlock('head');
// Trying to add <link rel="next" url="path-to-next-page" /> to head
// $block->getNextPageUrl() prints correct value
// But nothing is added to head
$head_block->addLinkRel( 'next', $block->getNextPageUrl() );
}
}
Is it possible at least, or I'm doing this in wrong way?
getBlock('page/html_pager')returns false in head. Here is code https://gist.github.com/anonymous/139e7e76343285f621e5 – Marvin3 May 24 '13 at 14:41null. Probably because it hasn't been initialized yet. It looks like it's impossible to move data from body to head, so I usedcreateBlockinstead ofgetBlock. – Marvin3 May 26 '13 at 12:39