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

XF 1.1 If Statement Code For Certain Forums

Discussion in 'XenForo Questions and Support' started by System0, Aug 9, 2012.

  1. System0

    System0 Active Member

    On my forum home page I have added a link for users to create new threads.

    To do this I editied the node_forum_level_2 template and changed:

    Code:
    <div class="nodeControls">
                <a href="{xen:link forums/index.rss, $forum}" class="tinyIcon feedIcon" title="{xen:phrase rss}">{xen:phrase rss}</a>
            </div>
    to

    Code:
    <div class="nodeControls">
    <xen:if is="{$visitor.user_id}">
    <a href="{xen:link forums/create-thread, $forum}" class="postnTopic">Post New Thread</xen:if>
                <a href="{xen:link forums/index.rss, $forum}" class="tinyIcon feedIcon" title="{xen:phrase rss}">{xen:phrase rss}</a>
            </div>
    I have two new forum rooms in which I only want a certain forum usergroup to post (authors). Permissions are working great but due to the above hack, there is still a link to post a new thread on the forum home page. I don't want a 'Post New Thread' link to show to unauthorised member groups.

    How would I modify the if statement above so that the 'Post New Thread' link is not shown on certain forum nodes.

    Thanks,
    Kevin
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    I haven't tested this, but you could try:

    Code:
    <xen:if is="{$visitor.user_id}">
    
    <xen:if is="!{$forum} == 9">​
    <a href="{xen:link forums/create-thread, $forum}" class="postnTopic">Post New Thread​
    </xen:if>​
    </xen:if>
    Where 9 is the forum you don't want it to be shown on.

    EDIT: If there's multiple forums, you could try this:

    Code:
    <xen:if is="{$visitor.user_id}">
    
    <xen:if is="!in_array({$forum}, array(9,10,11))">​
    <a href="{xen:link forums/create-thread, $forum}" class="postnTopic">Post New Thread​
    </xen:if>​
    </xen:if>
    Where 9,10,11 is again the forums you don't want to display the link on.

    If you'd rather do it the other way, and specify which forums you do want to display the link on, change the appropriate line to:

    Code:
    <xen:if is="in_array({$forum}, array(1,2,3))">
    
    Where 1,2,3 are the forums you do want it displayed.
     
    System0 likes this.
  3. System0

    System0 Active Member

    Thanks for the quick reply Chris. Appreciate it.

    I tried your suggestions. The first one didn't show the post new thread link for any forum room, the second suggestion showed it for all.
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    Sorry, untested, as I said.

    If I'd tested it, I'd have probably told you to use:

    {$forum.node_id} instead of {$forum}
     
    System0 likes this.
  5. System0

    System0 Active Member

    That worked great. Thanks Chris :)
     
    Chris D likes this.

Share This Page