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

Trophy System Problem

Micheal

Well-known member
#1
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

PHP:
public static function templateHook($hookName, &$contents, array $hookParams, XenForo_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" />
        </div>
    </li>';
        }
    }
   
    public static function criteriaUser($rule, array $data, array $user, &$returnValue)
    {
        switch ($rule)
        {
            case 'microquiz_correctanswers':
                    $returnValue = true;
            break;
        }
    }
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

Thanks
 

Attachments

Chris D

XenForo developer
Staff member
#2
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.