Conditional Statements

Conditional Statements

When working with the PAGE_CONTAINER template, you can pass variables from the view templates (category_view, forum_view,thread_view, etc.) using xen:container. The same applies to any templates which are included in the PAGE_CONTAINER template; theheader or ad_header templates for example.
To use the $forum.node_id variable for example, you would add this to the PAGE_CONTAINER template: <xen:container var="$forumId">{$forum.node_id}</xen:container>.
Similarly for the $threadId variable, you would add this: <xen:container var="$threadId">{$thread.thread_id}</xen:container>.
 
I'm sorry, that's doesn't mean anything to me.

I thought losing 50% of my adsense revenue since moving to XF was bad enough, now it looks like I'm going to lose all of it.
 
I added <xen:container var="$threadId">{$thread.thread_id}</xen:container> as the first line in the page container template.

Doesn't work, no change.

Also added it as first line in the ad templates, doesn't work.
 
So that's it?

Adsense account will now be blocked. Adsense earnings went from 100% on VB to 0% on XF for the record.

Thanks for your help.
 
@Brogan or anyone who knows.

Is it possible to do it backwards?

42. How can I show content to members who have completed a custom user field?
<xen:if is="{$visitor.customFields.field_id}">
This content will show to members who have completed the custom user field
</xen:if>
Note that field_id must be replaced with the actual custom user field identifier.


For someone who has NOT completed the user field.
 
same problem as @cjwinternet

for years i've been successfully preventing adsense from appearing on certain flagged threads by wrapping the adsense code in page_container_js_head using

Code:
<xen:if is="!in_array({$threadId}, array(43336,52702,46855,27897,84323,58726,28197,50759,81976,52186,53815,53126,59333,67655,22744))">

I have
Code:
<xen:container var="$threadId">{$thread.thread_id}</xen:container>
in page_container and everything works as expected.

Or rather, worked. Last Friday I received a warning email from gGoogle saying ads were appearing on thread 43336 and should be removed... I've no idea when the conditional stopped working, or what caused it.

edit: i'm also blocking all ads for sponsors with
Code:
<xen:if is="!{xen:helper ismemberof, $visitor, 9}">
in page_container_js_head, and that's still working fine
 
Last edited:
same problem as @cjwinternet

for years i've been successfully preventing adsense from appearing on certain flagged threads by wrapping the adsense code in page_container_js_head using

Code:
<xen:if is="!in_array({$threadId}, array(43336,52702,46855,27897,84323,58726,28197,50759,81976,52186,53815,53126,59333,67655,22744))">

I have
Code:
<xen:container var="$threadId">{$thread.thread_id}</xen:container>
in page_container and everything works as expected.

Or rather, worked. Last Friday I received a warning email from gGoogle saying ads were appearing on thread 43336 and should be removed... I've no idea when the conditional stopped working, or what caused it.

edit: i'm also blocking all ads for sponsors with
Code:
<xen:if is="!{xen:helper ismemberof, $visitor, 9}">
in page_container_js_head, and that's still working fine

disabling all addons via config.php doesn't help
 
There was a small mistake in the text, which has now been corrected (surprised it has taken four years to be noticed).

When working with the PAGE_CONTAINER template, you can pass variables from the view templates (category_view, forum_view,thread_view, etc.) using xen:container. The same applies to any templates which are included in the PAGE_CONTAINER template; theheader or ad_header templates for example.
To use the $forum.node_id variable for example, you would add this to the correct view template: <xen:container var="$forumId">{$forum.node_id}</xen:container>.
Similarly for the $threadId variable, you would add this: <xen:container var="$threadId">{$thread.thread_id}</xen:container>.
 
Hello,

I've read through this guide a few times and it is very helpful, so I am sorry if I've overlooked this, but is there a way to show content to a member of multiple user groups? Not show content to multiple user groups, but to a member of multiple user groups?

What I am after is a shorter version of....

<xen:if is="{xen:helper ismemberof, $visitor, v} AND {xen:helper ismemberof, $visitor, w} AND {xen:helper ismemberof, $visitor, x} AND {xen:helper ismemberof, $visitor, y} AND {xen:helper ismemberof, $visitor, z}">


Can this be done?

Thank you :)
 
There was a small mistake in the text, which has now been corrected (surprised it has taken four years to be noticed).

speaking as an idiot who couldn't follow the original text (yet apparently had done some years back when working on a different style), I think it needs to be even more explicit. I had assumed all the references to PAGE_CONTAINER meant the extra bit needed to go in there. So if it were me, I'd go with "Similarly for the $threadId variable, you would add this: <xen:container var="$threadId">{$thread.thread_id}</xen:container> to thread_view"?
 
I may flesh it out a bit more when I have some time later.

The view templates are explicitly mentioned in an earlier sentence though, so hopefully the association can be made relatively easily.
 
@RichardKYA, use this for a member who is in any one of mutliple groups:
Code:
<xen:if is="{xen:helper ismemberof, $visitor, x, y, z}">

Unless you mean the member must be a member of all of them, in which case you need to use AND as you have.
 
Hello,

I want to show an ad in certain forums but not for a specific user group.
I can use this condtional:
Code:
<xen:if is="in_array({$forum.node_id}, array(17, 53, 38, 33, 28, 29, 1, 7, 10, 56, 58, 74, 13))">
This content will show in forums x, y, and z
</xen:if>

(Numbers are forum id's)
But what with the user group? How can i put this in plz?
 
Back
Top Bottom