Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Display popular tags on discussion pages

Hi,

I'm using Vanilla 2.1.11. On the home page and on the page listing all discussions (url /discussions), popular tags are displayed in the left sidebar. However, when we are on the page of a specific discussion (url /discussion/ID), popular tags disappear from the sidebar. Is there a way to always display them in the sidebar?

Thanks a lot.

Comments

  • edited September 2015

    ok, go into the class.tagging.plugin.php file in the tagging plugin and look for this

    /**
        * Display the tag module on discussions lists.
        * @param DiscussionsController $Sender
        */
       public function DiscussionsController_Render_Before($Sender) {
          $this->AddTagModule($Sender);
       }
    

    replace it with this

           /**
            * Display the tag module on discussions lists and each discussion.
            * @param DiscussionsController $Sender
             *@param DiscussionController $Sender
            */
           public function DiscussionsController_Render_Before($Sender) {
              $this->AddTagModule($Sender);
           }
           public function DiscussionController_Render_Before($Sender) {
              $this->AddTagModule($Sender);
           }
    
  • Hi vrijvlinder,

    Thanks a lot for this very quick answer. Your code works great to display in the sidebar the tags of the current discussion. However, what I would like to achieve is to display all existing tags, exactly as in the home page. Is it possible?

    Regards.

  • peregrineperegrine MVP
    edited September 2015

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Hi peregrine,

    With your code, all tags are displayed in the sidebar (that's great). However, tags listed under a discussion (Tagged: tag1, tag2...) are no longer the ones specific to this discussion. It's simply all existing tags like in the sidebar.

    Actually, here's a little more info: categories are disabled in my forum, and only tags are used to organize discussions. So it would be useful to always have at hand a list of all tags in the sidebar (like it's the case by default with categories when they are enabled) while keeping valid the list of specific tags under each discussion.

    Thanks for your help.

  • edited September 2015

    Try adding the taggs module to your theme template , although that will show twice in the discussions page.... you might have to use css to hide the redundant module.

    {module name="TagModule" CssClass="Box"}

  • peregrineperegrine MVP
    edited September 2015

    With your code, all tags are displayed in the sidebar (that's great). However, tags listed under a discussion (Tagged: tag1, tag2...) are no longer the ones specific to this discussion.

    yes after I posted the code regarding Case statement, I realized the problem, and deleted it.

    adding module to theme - won't fix it unless the module retrieves all tags and is not re-used in the in-line tags.

    since the tagdata is used in both the panel box and the inline tags. pretty much the only way to do it, since the in-line tags and the popular tags box are joined at the hip within the discussion page

    I still thinks its not a good idea.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Thank you all for your help. Finally, I opted for creating a custom module and getting tags directly from the table GDN_Tag with Gdn::Database()->SQL(), then use the HTML code from /plugins/Tagging/class.tagmodel.php to format the list, then add my custom module in my theme template to output the result.

  • @Linc thinks you deserve the SolutionSayer badge no? I agree...

  • Thanks, done.

  • @jpfleury

    perhaps it would be better to use global case on all pages for panel via the plugin. and use the caching of tag-data to occur.

    and then create a separate lookup per DiscussionController Render for inline tags that gets pulled up within the discussion. since that will be different for each discussion.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Thanks a lot. It's a very small private forum, so caching is no big deal for the moment, but thanks for the suggestion.

Sign In or Register to comment.