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

XF 1.4 Display content differently on forum_list vs. forum_view

#1
Hi, how can I display content from a template differently when loaded through the forum_list template than when loaded through the forum_view template? I am trying to display a slightly different node_forum_level_2 template for the homepage vs. the forum view page. I have tried the following code with no luck. In fact, nothing shows at all:

Code:
<xen:if is="{$contentTemplate} == 'forum_list'">
Display content version 1
</xen:elseif />
Display content version 2
</xen:if>
Neither one displays anything.

According to Brogan's conditional guide, including how to find the correct template names, this should work.

24. How can I show content on a specific page?
<xen:if is="{$contentTemplate} == 'xyz'">
This content will show on the xyz template
</xen:if>
Via: https://xenforo.com/community/resources/conditional-statements.1604/

Help would be greatly appreciated.
 

Brogan

XenForo moderator
Staff member
#2
Ensure the variable is available in the template you are running the code.

You can check that by dumping it like so: {xen:helper dump, $variable}

Also, your else should just be <xen:else />.
 
#3
I typod the else tag. Sorry about that. Didn't work with that fixed either.

I tried the variable check you recommended and it returned "NULL".

So how then can I achieve what I'm aiming for? Basically, I want to display a different node_forum_level_2 template on the homepage than is displayed on the forum pages. Right now they both use the same template, so I tried to put the condition in that template. If I can create a new template and somehow use that instead for the subforum listings within a forum view page, that would work too. Is this possible, and if so, what is the best way to do it?
 

Brogan

XenForo moderator
Staff member
#4
If it's simple changes it could be done with CSS and specificity.

For structural changes though, having different template code is likely easier.
 
#5
Yes it's more than just CSS stuff. How can I specify to use a different template for each? If that works then that would be perfect for me.
 
#6
Does anybody know if this is possible? Sorry for the double post. Just anxious to get this up and running and I need to achieve this functionality in order to do so.