XF 1.1 If Statement Code For Certain Forums

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
 
I haven't tested this, but you could try:

Rich (BB 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:

Rich (BB 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:

Rich (BB code):
<xen:if is="in_array({$forum}, array(1,2,3))">

Where 1,2,3 are the forums you do want it displayed.
 
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.
 
Top Bottom