Programmatically render page_list filtered with current page's topics
Permalink
Hello,
I have pages with blog topics attached, and I have blog entries with blog topics attached.
I want to render a page list on page A which lists the blog entries which have at least one of the topics of page A.
I managed to do this more or less in this way:
This is not very elegant.
1.) How can I do this with $page_list_block->render("view")? I don't know how to add the $block_data to $page_list_block. And when I tried leaving out most of the block data, strangely only the pagination was rendered correctly, the list itself was empty.
It worked with
$page_list_block->render("templates/thumbnail_grid/view")
which is even more strange.
2.) Is there a way to add more than one topic to $block_data (I guess not).
Thank you very much for any advice!
Regards,
lu
I have pages with blog topics attached, and I have blog entries with blog topics attached.
I want to render a page list on page A which lists the blog entries which have at least one of the topics of page A.
I managed to do this more or less in this way:
$a11 = new Area('artikel'); $a11->display($c); //get topics $attributeKey = CollectionAttributeKey::getByHandle('blog_entry_topics'); $akHandle = $attributeKey->getAttributeKeyHandle(); $topics = $c->getAttribute($akHandle); $topicsID = $topics[0]->treeNodeID; //var_dump($topics); //create page list block $page_list_block = BlockType::getByHandle('page_list'); $block_data = array( 'num' => 3, // number of results 'includeName' => true, // include page name 'includeDescription' => false, 'truncateSummaries' => "1",
Viewing 15 lines of 34 lines. View entire code block.
This is not very elegant.
1.) How can I do this with $page_list_block->render("view")? I don't know how to add the $block_data to $page_list_block. And when I tried leaving out most of the block data, strangely only the pagination was rendered correctly, the list itself was empty.
It worked with
$page_list_block->render("templates/thumbnail_grid/view")
which is even more strange.
2.) Is there a way to add more than one topic to $block_data (I guess not).
Thank you very much for any advice!
Regards,
lu