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

Can someone explain this in a bit more detail?

xfrocks

Well-known member
#2
You can always ask me :D

Anyway, the idea is adding a event listener for init_dependencies, something like this:

PHP:
XenForo_Template_Helper_Core::$helpers['bamastangguy_ucwords'] = 'ucwords'
Then in the template, just use it like this:

Code:
{xen:helper BamaStangGuy_ucwords, $tag.tag_text}
Notice
  • The lowercase in $helpers['bamastangguy_ucwords'] is required
  • The mixedcase in {xen:helper} is not required, you can use bamastangguy_ucwords or bAmAsTaNgGuY_uCwOrDs or anything in between.
  • This code is not tested :D
 

Brent W

Well-known member
#3
You can always ask me :D

Anyway, the idea is adding a event listener for init_dependencies, something like this:

PHP:
XenForo_Template_Helper_Core::$helpers['bamastangguy_ucwords'] = 'ucwords'
Then in the template, just use it like this:

Code:
{xen:helper BamaStangGuy_ucwords, $tag.tag_text}
Notice
  • The lowercase in $helpers['bamastangguy_ucwords'] is required
  • The mixedcase in {xen:helper} is not required, you can use bamastangguy_ucwords or bAmAsTaNgGuY_uCwOrDs or anything in between.
  • This code is not tested :D

Thanks, I didn't want to bug you too much. You've been very helpful.
 

Brent W

Well-known member
#4
Bump, I never got around to looking too much into this. With the latest updates I'd like to take a stab at it again (i hacked my copy on one site a lot and would rather do it right with the update). Anyone with more knowledge than me care to take a stab at making this happen? Where would I actually put this code?
 

Brent W

Well-known member
#7
Well I took a shot at this and still can't get it to ucwords the title tag.

Code:

Helpers.php
PHP:
<?php
//Our class helper (we can put any helpers in here we want)
class UcWords_Helpers
{
    public static function ucWords($string)
    {
        //We only return the argument, dont do nothing.
        return $string;
    }
}
Listeners.php
PHP:
<?php
//Our class name
class UcWords_Listener
{
    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(
            'ucwords' => array('UcWords_Helpers', 'ucWords')
        );
    }
}
Event Listener:
Screen Shot 2013-03-05 at 5.42.57 PM.png