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

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

Discussion in 'XenForo Development Discussions' started by tenants, Oct 2, 2011.

  1. tenants

    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)
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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?
  3. Floris

    Floris Guest

  4. tenants

    tenants Well-Known Member

    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)
  5. tenants

    tenants Well-Known Member

    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)
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    It takes any boolean expression. There are some syntax differences.

    1) Variables are enclosed in curlies.

    2) Array indexes are accessed like this:

    Instead of like this:

  7. tenants

    tenants Well-Known Member

    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
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Some PHP functions are also allowed in conditions. They are defined here:


    		$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:


    Here are some examples:

    http://xenforo.com/community/thread...-node_list-categories-loop.20211/#post-259022 (using in_array)
    http://xenforo.com/community/thread...age-displayed-based-on-day.19176/#post-246411 (using the xen:time function in a condition)
    Akela likes this.
  10. Floris

    Floris Guest

    My XenForo handy-bookmarks are over 200 .. it's not handy anymore!
  11. tenants

    tenants Well-Known Member

    :) ...

    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"

Share This Page