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

XF 1.1 IF statement to display specific content.

Discussion in 'XenForo Questions and Support' started by zagman76, Oct 19, 2012.

  1. zagman76

    zagman76 Member

    When I was using vB, I was able to add an 'if' statement to only display certain content (ads) in specific forums. Actually, it was configured to NOT display the ads in specific forums (to comply with the AdSense rules).

    Is there a similar method in XenForo? In addition, can it be combined to also not show for specific user groups?

    Here is what I was using on vB:
    <vb:if condition="!in_array($GLOBALS[forumid], array(23,29,32,40,49,62,76,84,99,101))">
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    <xen:if is="!in_array({$forum.node_id}, array(23,29,32,40,49,62,76,84,99,101)) AND !{xen:helper ismemberof, $visitor, 4,5,6}">
    zagman76 likes this.
  3. zagman76

    zagman76 Member

    Perfect!! Thank you!
  4. TrevC

    TrevC Well-Known Member

    Somewhat off topic, but I was just curious if the following is also considered correct/valid:
    <xen:if is="{$message.canReport} OR {$message.canEdit}">
  5. Chris D

    Chris D XenForo Developer Staff Member

    Hi TrevC,

    This all depends on where you want to use those conditionals.

    Some templates might not have the $message parameter available. In fact, some templates instead use the $post variable.

    Other templates might even use specific variables passed from the controller... I'm pretty sure I've seen {$canReply} before now...

    Best bet is, to try a conditional, if it doesn't work then specifically make a new thread somewhere detailing exactly what conditional you're trying to put in which template and ultimately what you hope to achieve and hopefully we will be able to work out a solution.

    Some things unfortunately need custom PHP to be written.
    Jake Bunce likes this.
  6. TrevC

    TrevC Well-Known Member

    Thanks. It's working. Must've been used in the correct context. :)

    We have a large portion of iOS and Mac users, so I've been reworking the public and private controls on posts with better touch targets and a more modern UI.
    Screen Shot 2012-11-21 at 22.14.41.png

    The private controls are toggled by clicking the cog.
    Screen Shot 2012-11-21 at 22.15.15.png

    Icons, spacing, sizing, etc is not refined or complete. Actually, the design still has a way to go.
    Our CSS is already smaller/faster than the original Xenforo stuff.

    I love Xenforo, but I've never been a fan of how template editing is handled, or any of the stock design & styles.
  7. Chris D

    Chris D XenForo Developer Staff Member

    That looks awesome.

    People will be bugging you to release that...
  8. TrevC

    TrevC Well-Known Member

    Thanks. I'm happy with it so far. The pages render quicker too.

    I'd release a generic version if it were possible, but there's tons of templates modded, markup stripped back, re-structuring and renaming. The CSS loads as a single minified file, the stock Xen CSS loading is all removed from the templates. In re-writing the CSS (Sass), the emphasis was placed on fast performance for webkit/mobile Safari. We're also only supporting IE9+ (though IE8 still works quite well).

    There's only two raster images in use, the rest is a custom webfont.

    "Speed is a feature" :)

Share This Page