Conditional Statements

Conditional Statements

Is it possible to do s conditional for words on page? I'd like to have an ad show if there are more than 500 words on the page.
 
Trying to add content using this in ad_message_body:

33. How can I show content in more than one post?
<xen:if is="in_array({$post.post_id}, array(x, y, z))">
This content will show in posts x, y, and z
</xen:if>


Or rather this:

<xen:if is="in_array({$post.post_id}, array(1, 5, 10))">
This content will show in posts x, y, and z
</xen:if>


But it doesn't appear to be showing.

If I use other conditionals it does work. So guests conditional or whatever.

What am I doing wrong?


same here. any idea, why this doesn't work with xf 1.5?

thank you
 
same here. any idea, why this doesn't work with xf 1.5?

thank you
Add this to ad_message_below

<xen:if is="{$visitor.message_count} < 50">
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND {$thread.reply_count} > 0">
<div align="center">
YOUR AD
</div></xen:if></xen:if>

That's below post 1, and for people with less than 50 posts.

<xen:if is="{$visitor.message_count} < 50">
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 5 AND {$thread.reply_count} > 7">
<div align="center">
YOUR AD
</div></xen:if></xen:if>

And this one will show an ad in post 5 if there are 7 or more posts, and to people with less than 50 posts.

And it'll show neatly under the message body area so as to not confused with the actual content. I have a responsive adsense slot in there, and it looks lovely in all sized screens on all devices. Google does a good job of the responsive ad serving these days.
 
thx, donny.



i want show ads after post 1, 5, and 10 on every page in a thread. i can't find a solution for that. a good example i saw on macuser:
http://www.macuser.de/threads/partition-fuer-altes-system-erstellen.753577/

Use the two above and then the following too.

<xen:if is="{$visitor.message_count} < 50">
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 10 AND {$thread.reply_count} > 10">
<div align="center">
YOUR AD
</div></xen:if></xen:if>

And remove the visitor message count conditional from them all if you want to show them to all users. I tend to find your CTR drops though from regulars who get ad-blind. So I tend to mess around with the 50 above and switch it to 100 every now and again to see what happens.
 
So I put in a banner specific to each sub forum I have but a few special threads we have want to use a specific banner for the thread itself.

<xen:if is="{$forum.node_id} == 5">
<img src="@imagePath/uix_dark/screenshot.jpg" alt="{$xenOptions.boardTitle}" />
<xen:elseif is="{$forum.node_id} == 3" />
<img src="@imagePath/uix_dark/othergames.png" alt="{$xenOptions.boardTitle}" />
<xen:elseif is="{$forum.node_id} == 25" />
<img src="@imagePath/uix_dark/tabletop.png" alt="{$xenOptions.boardTitle}" />

That is what I have put in my logo block (edited out 20 more sub forums) to display a different banner for each sub but I can't figure out how to do it for a thread.

<xen:elseif is="{$threadId} == 82">
<img src="@imagePath/uix_dark/guns.png" alt="{$xenOptions.boardTitle}" />

I tried that but it won't take it. Is $threadId not the right syntax or is it in the wrong .css file? Or is there something else entirely I am missing?
 
I'm not sure what you mean by "logo block" but the node ID likely isn't exposed to whatever template you have added the code to.

You may be able to pass it in using xen:container - see this guide: https://xenforo.com/community/resources/using-variables-in-templates.5034/update?update=18416
By logo block I mean the logo_block.css which is a template in the master style and all of my subsequent styles. That is where I have placed my "banners" for each sub forum.

It allows me to select an image for {$forum.node_id} but not one for {$threadId}. Maybe that .css doesn't allow that or maybe I have the syntax wrong.

I am reading the link you gave me to see what I can figure out from there.
 
You can't use conditional statements in css templates.
I think I am misunderstanding the difference in the template area.

admin.php?templates/logo_block.243/ <-- this is the file I am editing on my forum and I have a ton of these statements to supply a different banner to each forum.

<xen:if is="{$forum.node_id} == 5">
<img src="@imagePath/uix_dark/screenshot.jpg" alt="{$xenOptions.boardTitle}" />
<xen:elseif is="{$forum.node_id} == 3" />

It works like a charm. I have about 20 of those in there.

I want to put one in for a thread specific logo block instead of the standard forum node one.

<xen:elseif is="{$threadId} == 82">
<img src="@imagePath/uix_dark/guns.png" />

That is how I read it should look but it won't allow me to do so.
 
So I did not pay attention to the error that I was getting of course, it said there was an error on line 53 of my file which was the trailing /a before the /div.

That made me pay attention that I didn't have a closing slash on the xen:elseif is so I fixed that.

<xen:if is="{$forum.node_id} == 25">
<img src="@imagePath/uix_dark/tabletop.png" alt="{$xenOptions.boardTitle}" />
<xen:elseif is="{$threadId} == 82" />
<img src="@imagePath/uix_dark/guns.png" alt="{$xenOptions.boardTitle}" />

<xen:elseif is="{$forum.node_id} == 5" />
<img src="@imagePath/uix_dark/screenshot.jpg" alt="{$xenOptions.boardTitle}" />
<xen:elseif is="{$forum.node_id} == 3" />
<img src="@imagePath/uix_dark/othergames.png" alt="{$xenOptions.boardTitle}" />
<xen:else />
<img src="@headerLogoPath" alt="{$xenOptions.boardTitle}" />
</xen:if>

So that is what my block looks like (a bunch truncated in the middle for brevity) but it is of course still not showing the guns.png I want in the logo_block. The part highlighted in red is what I am trying to activate. All the other ones work. That thread #82 is under node #5 so I placed it above and below the elseif for forum.node_id 5 to see if that would change it and it does not.

I have looked at it and logo_block is the only template I have found that manipulates the logo_block of course, I assumed that I could pull it in thread_view but I don't see a call for the logo in that template. I am still looking into it but I like to talk out loud when I am searching a problem.
 
Okay so I got it working with a friend and this is how we did it.

I went into thread_view and made the following change:

<xen:title>{xen:helper threadPrefix, $thread, escaped}{$thread.title}{xen:helper pagenumber, $page}</xen:title>
<xen:h1>
<xen:if is="{$thread.thread_id} == 82">
<a href="{xen:link threads, $thread}"><img src="@imagePath/uix_dark/guns.png" alt="{$thread.title}" /></a>
<xen:else />

{xen:helper threadPrefix, $thread}{$thread.title}
</xen:if>
</xen:h1>

The highlights in red are the changes I made. What this does is allow you to have a logo for the actual thread itself in place of the $thread.title variable.
 
Please tell me, what is wrong with this?

<xen:if is="{$link}=='http://' ">
No website
<xen:else />
{$link}
</xen:if>

-------- 2 minutes later ...
Ok, it is right, i made another fault. :)
 
How can I show a content on "ad_thread_view_below_messages" only if the thread has 5 post and above?
 
16. How can I show content after the first post in a thread?
<xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">
This content will show after the first post on the first page only
</xen:if>

Can you not use that, replacing 0 with 4?
 
  • Like
Reactions: rdn
Hi,
I wonder if someone can help me get the right expression to add content to a specific resource description page - whatever I've tried doesn't work :(
Thanks.
 
Top Bottom