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

Use option in template conditional

Discussion in 'XenForo Development Discussions' started by SimonV, Jan 3, 2015.

  1. SimonV

    SimonV Well-Known Member

    I have an option that I want to use the output in a template condition, the option is a PHP Callback - Array as seen below:

    using this code that I found somewhere here on the forums:


    class AddToHomeSceen_Options_UserGroupChooser extends XenForo_Option_UserGroupChooser
        public static function 
    renderCheckbox(XenForo_View $view$fieldPrefix, array $preparedOption$canEdit)
    Up to this point I'm fine, I have the option as I need it but now I'm stuck in how to utilise this with a template conditional as the output.

    Im looking for a simple way to include user groups in a template condition that are set in an addon's options so if there are better ways to do this please do advise me as Im a total newbie when it comes to XenForo addon creation.

    EDIT: Actually it might be better to just not include my js file for certain usergroups, I have the file included using addRequiredExternal in my addon Listener file.
    Last edited: Jan 4, 2015
  2. SimonV

    SimonV Well-Known Member

    Well I'm slowly learning my way around. In the end a achieved what I wanted all be it a very basic version of what I was trying to do. I used a Text Box - String Field instead with a comma separated value entered and then added my js and css files with the following:

    $visitor XenForo_Visitor::getInstance();
    $xenoptions XenForo_Application::get('options');
    $user_group_id $xenoptions->myOptionName;
    $user_group_id explode(','$user_group_id);

    I now want to use that same option array in a template, how would I go about doing that, any pointers would be great as if I try to use the string value in a conditional only the first value is recognised.

Share This Page