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

xenSyntax

Discussion in 'XenForo Development Discussions' started by Serialize, Mar 11, 2012.

  1. Serialize

    Serialize New Member

    Is there a guide, other than the [very sparse, time consuming] series of posts on this forum, to the xen template syntax?

    We want to customize some aspects of the software, and having to learn it in the process.
    At the moment, we are trying to do, sing the forum_view template, is a conditional test to change the link to the post button based on which forum the user is in. Base template code is:

    <xen:if is="{$canPostThread}">
    <xen:set var="$newDiscussionButton"><a href="{xen:link 'forums/create-thread', $forum}" class="callToAction"><span>{xen:phrase post_new_thread}</span></a></xen:set>
    <xen:if is="!{$renderedNodes}">
    <xen:topctrl>{xen:raw $newDiscussionButton}</xen:topctrl>
    </xen:if>
    </xen:if>



    What we would like to do is something more like this:

    switch($forum)
    case "gaming"
    <xen:set var="$newDiscussionButton"><a href="{xen:link 'somewhere-else', $forum}"
    case "tennis"
    <xen:set var="$newDiscussionButton"><a href="{xen:link 'post_in-tennis', $forum}"
    ...
    ...
    And so on. Obviously I am coming form a different programming background there, hence wanting to know more about the syntax, globals, etc.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    There is no "switch" construct you can use in the templates, but you can use this:

    Code:
    <xen:if is="{$forum.node_id} == 1">
    	FOR FORUM 1
    <xen:elseif is="{$forum.node_id} == 2" />
    	FOR FORUM 2
    <xen:elseif is="{$forum.node_id} == 3" />
    	FOR FORUM 3
    <xen:elseif is="{$forum.node_id} == 4" />
    	FOR FORUM 4
    <xen:else />
    	FOR ALL OTHER FORUMS
    </xen:if>
    
     
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

Share This Page