I am trying to make an addon that adds a new helper to xenforo. I called this helper simply "rank" and it displays a rank dependent from the users post count.
I did this tutorial and am at step 4, where I add the function of my helper and am stuck.
Here is what I have so far:
Listener.php:
Helpers.php:
Currently I have this code in my messega_user_info template that I want to call with my new helper:
Basically what I want to achieve is whenever I put
{xen:helper rank, $something}
in a template, it should call the template code from above.
I did this tutorial and am at step 4, where I add the function of my helper and am stuck.
Here is what I have so far:
Listener.php:
PHP:
<?php
//Our class name
class UserRank_Listener
{
/**
* Listen to the "init_dependencies" code event.
*
* @param XenForo_Dependencies_Abstract $dependencies
* @param array $data
*/
public static function init(XenForo_Dependencies_Abstract $dependencies, array $data)
{
//Get the static variable $helperCallbacks and add a new item in the array.
XenForo_Template_Helper_Core::$helperCallbacks += array(
'rank' => array('UserRank_Helpers', 'helperRank')
);
}
}
?>
Helpers.php:
PHP:
<?php
//Our class helper (we can put any helpers in here we want)
class UserRank_Helpers
{
public static function helperRank ($string)
{
//We only return the argument, dont do nothing.
return $string;
}
}
?>
Currently I have this code in my messega_user_info template that I want to call with my new helper:
HTML:
<xen:if is="{$user.message_count} > 29 AND {$user.message_count} < 100">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank1.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 99 AND {$user.message_count} < 300">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank2.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 299 AND {$user.message_count} < 600">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank3.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 599 AND {$user.message_count} < 1000">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank4.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 999 AND {$user.message_count} < 1500">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank5.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 1499 AND {$user.message_count} < 2000">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank6.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 1999 AND {$user.message_count} < 2500">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank7.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 2499 AND {$user.message_count} < 3000">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank8.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 2999 AND {$user.message_count} < 3500">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank9.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 3499 AND {$user.message_count} < 4000">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank10.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 3999 AND {$user.message_count} < 4500">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank11.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 4499 AND {$user.message_count} < 5000">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank12.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 4999 AND {$user.message_count} < 5500">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank13.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 5499 AND {$user.message_count} < 6000">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank14.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 5999 AND {$user.message_count} < 6500">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank15.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 6499 AND {$user.message_count} < 7000">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank16.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 6999 AND {$user.message_count} < 7500">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank17.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 7499 AND {$user.message_count} < 8000">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank18.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 7999 AND {$user.message_count} < 8500">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank19.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 8499 AND {$user.message_count} < 10000">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank20.png">
</li>
</xen:if>
<xen:if is="{$user.message_count} > 9999">
<li class="pairsInlineranks">
<img src="styles/mystyle/xenforo/ranks/rank21.png">
</li>
</xen:if>
Basically what I want to achieve is whenever I put
{xen:helper rank, $something}
in a template, it should call the template code from above.