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

Trophy System Problem

Discussion in 'XenForo Development Discussions' started by Micheal, Sep 2, 2014.

  1. Micheal

    Micheal Well-Known Member

    Hi everyone

    I hope someone will help me with this but im trying to add a new trophy for my add-on

    Here is what i have in the Listener

    public static function templateHook($hookName, &$contents, array $hookParamsXenForo_Template_Abstract $template)
            if (
    $hookName == 'user_criteria_content')
    $userCriteria $template->getParam('userCriteria');
    $checked $userCriteria['microquiz_correctanswers'] ? 'checked' '';
    $answers $userCriteria['microquiz_correctanswers']['answers'];
    $contents .= '<li><label>
            <input type="checkbox" name="user_criteria[microquiz_correctanswers][rule]" value="microquiz_correctanswers" class="Disabler" id="ucrit_microquiz_correctanswers" '
    .$checked.' />
            User has got aleast X correct answers in microquiz:</label>
            <div class="criteriaQualifier" id="ucrit_microquiz_correctanswers_Disabler">
                <xen:spinbox name="user_criteria[microquiz_correctanswers][data][answers]" value="'
    .$answers.'" size="5" min="10" step="5" />
        public static function 
    criteriaUser($rule, array $data, array $user, &$returnValue)
            switch (
    $returnValue true;
    This works fine but its not showing the spinbox when i go and add a trophy
    If anyone could help me here that would be great


    Attached Files:

  2. Chris D

    Chris D XenForo Developer Staff Member

    You really should be using the template modification system rather than template hooks, and therefore you can inject actual XenForo templates which would compile XenForo template syntax.

    All you're doing right now is injecting raw HTML into some existing HTML. Your HTML code will therefore just contain <xen:spinbox> and that is not valid HTML, your browser won't know what to do with it. If you do it properly through the TM system it will work as the xen syntax will get compiled.
  3. Micheal

    Micheal Well-Known Member

    thank you thought it was something to do with that.
  4. Micheal

    Micheal Well-Known Member

    thank you its now working as it should be.
    Chris D likes this.
  5. Micheal

    Micheal Well-Known Member

    just one other question how would i award the points in my add-on now if they get x questions right

Share This Page