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

{$canSearch} not working?

Discussion in 'XenForo Development Discussions' started by Astrum, Mar 30, 2011.

  1. Astrum

    Astrum Active Member

    Alright, I'm not sure if this is a bug or I'm going crazy. I'm trying to add a sub-navigation tab inside of <xen:if is="{$canSearch}">blah blah blah</xen:if>. Now presumably this should work as not too far above it a sub-navigation tab does the same thing, namely this bit under the Forums tab:

    Code:
    <xen:if is="{$canSearch}"><li><a href="{xen:link search, '', 'type=post'}">{xen:phrase search_forums}</a></li></xen:if>
    Now the problem is that while the search forums subnav works just fine, only displaying to those who are allowed to search, any custom tab using this permission will never be shown.

    So am I losing my mind or is the $canSearch being removed from the params array right after it's used in the Forums navigation group?
     
  2. Arik

    Arik Well-Known Member

    $canSearch isn't available to your template.

    You'll need to hook into the template_create event and add that parameter.
     
  3. Astrum

    Astrum Active Member

    I don't think a linksTemplate goes through template_create, I tried monitoring for it and it never went through. I looked at HtmlPublic.php and found:

    PHP:
    $extraTab['linksTemplate'] = $this->createTemplateObject($extraTab['linksTemplate'], $extraTab);
    So it's passing $extraTab as the parameters. I'm just setting $extraTab['canSearch'] = $visitor->canSearch() and it works fine.
     

Share This Page