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

xen syntax in scripts

Discussion in 'XenForo Development Discussions' started by tehMorag, Jul 17, 2014.

  1. tehMorag

    tehMorag Member

    Hey there,
    Been trying my hand at make my own addons for my site.
    I have found that if I want to read/write info from a database in a php script (XenForo or external), I need to use the <xen:callback> tag in the templete

    What I am currently trying to do is get xen syntax working in on of these scripts. The main one I am trying to make is limit the visablilty of a few things to admin/mods only.
    I would normally use <xen:if is="{$visitor.is_admin} OR {$visitor.is_moderator}"> but it isnt working.

    Will I have to call the usergroup via php instead of using xen syntax or is there a way to be able to use the syntax in php scripts... Anything that could help me out here?

  2. Chris D

    Chris D XenForo Developer Staff Member

    To get the visitor object in PHP:
    $visitor XenForo_Visitor::getInstance();
    if ($visitor->is_admin || $visitor->is_moderator)
    // Do stuff here
    tehMorag likes this.
  3. tehMorag

    tehMorag Member

    Awesome thank you!
    Is there a resource that I am missing that has a list of calls?
    I can see that the IF statement is easily translatable but does this work for the rest of the xen template commands?
  4. Chris D

    Chris D XenForo Developer Staff Member

    Some, but not all.

    The best resource is the XenForo code, or you know, just ask here if there's anything you're unsure about or can't find :)
    tehMorag likes this.

Share This Page