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

How to use a xenForo variable within my own class

Discussion in 'XenForo Questions and Support' started by mungo, Apr 1, 2011.

  1. mungo

    mungo New Member

    I've built a simple add-on and code event listener based on the tutorial.

    it works fine if i just want to replace some text (yes i know i can do this with phrases) however it doesn't when the replace alo includes a xenForo phrase (or variable for that matter).

    what i am trying to do is actually add a title tag to the link back to my homepage.

    here is my current code:

    class Mungo_listener
    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    if($hookName == 'footer_links')
    $contents = str_replace('>{xen:phrase home',' title="here is a friendly title">{xen:phrase home',$contents);

    so two questions, how can i do this by the method i'm trying.
    would there be a better way of doing this?
  2. Kier

    Kier XenForo Developer Staff Member

    Phrases are compiled into the template, so you need to search for the text of the phrase, not the phrase markup.
  3. mungo

    mungo New Member

    great thanks, i've done as you said and it works as i wanted it to.

    ... am slowly getting the hang of xenForo, it's very different to what i'm used to!
    Kier likes this.

Share This Page