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

Inline Modification Of Helper Data

Discussion in 'XenForo Development Discussions' started by ibnesayeed, Jan 1, 2011.

  1. ibnesayeed

    ibnesayeed Well-Known Member

    I don't have much expertise in such template languages. Can someone please help me with this.

    In the Member Card template it uses a helper function to grab the appropriate CSS string to center/middle align the avatar. Which essentially is a calculated 'left' and 'top' properties depending upon the avatar width and height. But when using it in RTL mode, CSS property 'right' should be used instead of left with the exact same value as of 'left'.

    Now I don't want to modify the core files, instead, if I can somehow apply str_replace on the returned string in the template file of the specific style only then I will be good to go.

    Here is the related code:

    <img src="{xen:helper avatar, {$user}, l}" alt="" style="{xen:helper avatarCropCss, $user}{$_avatarStyle}/>
    {xen:helper avatarCropCss, $user} portion of the above line returns a string like "left: 48px; top: 42.5px;". Now I want to change that 'left' to 'right'.

  2. Shadab

    Shadab Well-Known Member

    I'm not aware of any helper or tag which would do string replacement.
    You can try overriding the "avatarCropCss" helper itself.

    1. Create your own helper which would call the native avatarCropCss helper and do the necessary string replacement before returning the result. Sample untested code:
    class Sayeed_Template_Helper_Core
        public static function 
    helperAvatarCropCss($user$center false)
    $css XenForo_Template_Helper_Core::helperAvatarCropCss($user$center);

            if (!

    2. Create a new event listener which would replace xenforo's avatarCropCss callback with your helper's callback. You can use my template helper as a reference (the core php code is documented):

    ยป http://xenforo.com/community/threads/gp-template-helper-for-usergroups.6271/
    ibnesayeed likes this.
  3. ibnesayeed

    ibnesayeed Well-Known Member

    Thanks Shadab, I hope it will help and do the trick. :)

Share This Page