Keyword

How to get tag's id in url?

  • Lech Zbigniew Dutkiewicz
  • Lech Zbigniew Dutkiewicz's Avatar Topic Author
  • Offline
  • New Member
More
11 years 4 months ago #113183 by Lech Zbigniew Dutkiewicz
How to get tag's id in url? was created by Lech Zbigniew Dutkiewicz
Hi,

My site uses tag's cloud as one of sidebar menus.
I need to be able to add "active" class to chosen option when viewing items list by tag.
I tried to copy solutions from category menu in K2 tools but this needs category id in url to compare. How can I implement it to my site?

Here's what I made with tags.php (now it compares by tag-name, but JRequest gets it without polish letters and without spaces):
<div id="k2ModuleBox<?php echo $module -> id; ?>" class="k2TagCloudBlock<?php
        if ($params -> get('moduleclass_sfx'))
                echo ' ' . $params -> get('moduleclass_sfx');
 ?>">
        <?php
        $tagname = JRequest::getCmd('tag');
        $task = JRequest::getCmd('task');
        $output;
        $output .= '<ul class="level' . $level . ' menu">';
        foreach ($tags as $tag) :
                if (!empty($tag -> tag)) :
                        if (($task == 'tag')&& ($tagname == $tag -> tag)) {
                                $active = 'active';
                        } else {
                                $active = '';
                        }
                        $output .= '<li class="' .$active.'" "'. $tag -> tag . '"><a href="' . $tag -> link . '">' . $tag -> tag . '</a></li>';
                endif;
        endforeach;
        $output .= '</ul>';
        echo $output;
        ?>
        <div class="clr"></div>
</div>

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum