1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Sidebar Addon Visibility issues

Discussion in 'Troubleshooting and Problems' started by AscendancyGaming, Aug 15, 2012.

  1. We've set up a sidebar addon a while ago that allows people to see who is online on our Mumble (voice chat) server. Recently we decided it would be better to make that only visible to members of our site, rather than to everyone by default.

    I was able to find on the site here that if I add the following code (in red, the rest is what we used previously), it should make the viewer only viewable to usergroup 8 (our members usergroup):

    The problem I'm seeing now is that no matter who logs in, no one can see the addon at all. Did I miss something? Is there another step needed along the way? Removing the recently added code takes it right back to being visible to everyone again.

    Any thoughts or suggestions on this would be greatly appreciated.
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Your code is correct.

    What template is that in? Maybe $visitor isn't available. You can debug it by adding this code:

    {xen:helper dump, {$visitor}}
  3. Hi Jake, thanks for your response here.

    The template is a custom template I created under Default Style. I've added the debug code you suggested to the template code and now I'm seeing NULL displayed above the iframe content. From this, I'm assuming your assumption that $visitor isn't available is correct. Do you have any suggestions on how to rectify that?
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  5. Hi Jake, thanks again for your response and help on this.

    I've created this by setting up a template hook in Code Event Listeners, under the Development section of the Admin Control Panel.
    The Listener.php file I set up for it has the following code:
    * This is our callback class.
    * We must define a callback class to be used in the code event listener.
    class MumbleViewer_Listener
        * This is our callback method. It uses 4 params. This method will check if the current requested hook is what we want ('forum_list_sidebar')
        * and if it is, we will insert in the contents our template. This way we will have a sidebar right after the XenForo default sidebar.
        public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
            /* If this hook is what we want! Remember: we have found the hook name when we was looking in the forum_list template! */
            if ($hookName == 'forum_list_sidebar')
                /* Insert our template in the contents. This way our sidebar will be inserted right after the last XenForo sidebar in the forum list page */
                //$contents .= $template->create('mumble_sidebar');
                /* If you want that our sidebar be BEFORE the XenForo sidebars uncomment the following line (don't forget to comment the line above) */
                $contents = $template->create('mumble_sidebar') . $contents;
    I hope that helps. I was using the instructions on how to add a new sidebar in the forum list (found here)
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    AscendancyGaming likes this.
  7. Thanks so much, Jake, I'm now able to confirm it's working as intended in that we can limit the visibility of this custom addon by usergroup! Once again you were able to help me noodle though this and your help is very much appreciated!

Share This Page