How to get the current topic link inside [page-list] block

Permalink 2 users found helpful
The topic list is new and missed docs. I want to create a custom "page-list" template (for each page in the list print topic: name + url)

** Example (each topic in page-list is clickable to the "topic category")
http://www.sitepoint.com/

siton
 
siton replied on at Permalink Reply
siton
If someone want - i find a little "weird" solution (I hope someone give me more elegant solution). Anyway this is really useful for categories blogs (sitepoint blog has really great UI/X)

The steps:
1)I copy and paste the function getTopicLink from "topiclist" controller to "pagelist" controller (in the future i will create custom controller)

2)Inside foreach ($pages as $page): --- i added this code:
$topics = $page->getAttribute('blog_topics_handle'); //get array of topic by topic handle 
foreach($topics as $topic) {?>
      <a href="<?php echo $view->controller->getTopicLink($topic); ?>">//get topic link value
     <?php 
   print $topic->getTreeNodeDisplayName(); //display topic name
       ?>
</a>
<?php   }?>

The output for "pagelist" item with : #animation #css topics activate.
<a href="http://localhost/concrete5_test_8/blog/topic/13/animation">Animation            </a>
<a href="http://localhost/concrete5_test_8/blog/topic/16/CSS">CSS</a>


***no checking "if" "$topics" is object. This is partly code
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi siton,

Here is something you can try for adding topics and their links in page list items without overriding or modifying the Page List controller:
<?php
/*Display page topics and topic links for filtering the page list*/
// get the current page list item topics for a specific topic tree
$topics = $page->getAttribute('blog_entry_topics');
// if $topics is true, loop through each topic
// - var_dump(is_object($topics)); is false
if ($topics) {
    // topics wrapper container (optional)
    echo '<div class="ccm-block-topics-wrapper">';
    foreach ($topics as $topic) {
        // get the tree node ID
        $treeNodeID = $topic->getTreeNodeID();
        // get the tree node name
        $treeNodeName = $topic->getTreeNodeDisplayName();
        // make the tree node name ready for use in a URL

In your Page List block custom template, this code would go inside your "foreach ($pages as $page)" loop. I have commented the code and will create a tutorial for it soon.

It should handle Hebrew and other languages.
stewblack23 replied on at Permalink Reply
stewblack23
Thanks MrKDilkinton. Was just looking for this in a project I'm working on.