<xen:if is=" {} OR {}"

tenants

Well-known member
I know the

<xen:if is="{} AND{}"

statement exists, but is there an equivalent for OR, I've just tried the statement in the title and the ACP is throwing evil warnings at me

<xen:if is="{$foo} OR {$bar}"> doStuff </xen:if>

A link to the documentation would be useful to answer this (I'll get things done much quicker once I know what's available, currently I'm doing a lot of trial and error)
 
You got it right. It just takes a boolean expression. Any boolean operator works including AND and OR.

What is the error you are getting? And what code is generating that error?
 
I was being stupid, I dropped of the dollar signs on the params (why do I ever admit to my ridiculous errors... I'll never know)

Is there any documentation on this ? (not my ridiculous errors, I'm sure there are many specs on my errors, all of which 50 inches THICK)

... ah cheers Floris (got there before my reply)
 
Ah, that's not quite a spec

There must be some sort of design / functional spec for the xen ACP markup

(The meatier the better, I'm done with being a veggie and want to get my hands dirty with these plug-ins)
 
It takes any boolean expression. There are some syntax differences.

1) Variables are enclosed in curlies.

2) Array indexes are accessed like this:

Code:
{$array.index}

Instead of like this:

Code:
{$array[index]}
 
Thanks, got it... (and even if the param returns a string, it seems to be possible to use as a bool, the only thing that seem to returns false is null and 0, ....and possibly bools too)

but there are quite a few expressions and ways of writing them, I've solved my silliness for now, but is there currently no released documentation?

This must have been written with some sort of requirement documentation, design spec, functional spec, test spec.... even if it's on the back of a handkerchief... a photocopy of that would be useful
 
Some PHP functions are also allowed in conditions. They are defined here:

XenForo_Template_Compiler::_parseConditionExpression

Code:
		$allowedFunctions = 'is_array|is_object|is_string|isset|empty'
			. '|array|array_key_exists|count|in_array|array_search'
			. '|preg_match|preg_match_all|strpos|stripos|strlen'
			. '|ceil|floor|round|max|min|mt_rand|rand';

You can also use template helpers and named functions which are useful in some conditions:

http://xenforo.com/community/threads/when-will-we-see-a-developer-documentation.13779/#post-182516
http://xenforo.com/community/threads/when-will-we-see-a-developer-documentation.13779/#post-181713

Here are some examples:

http://xenforo.com/community/thread...-node_list-categories-loop.20211/#post-259022 (using in_array)
http://xenforo.com/community/thread...t-post-and-only-in-threads.13968/#post-256571
http://xenforo.com/community/thread...age-displayed-based-on-day.19176/#post-246411 (using the xen:time function in a condition)
 
My XenForo handy-bookmarks are over 200 .. it's not handy anymore!
 
:) ...

Yeah, get them all stapled together and you have your self a pretty good doc..

Okay, so the official line from looking at those links is "The Docs are on there way... no expected date yet"
 
Top Bottom