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

Modify phrase dynamically?

Discussion in 'XenForo Development Discussions' started by Kevin, May 6, 2013.

  1. Kevin

    Kevin Well-Known Member

    Has anybody modified a phrase yet dynamically at run-time? What I'd like to do is to globally modify a phrase dynamically from an add-on when it is active.



    (I suspect the method is simple but it is late and I'm not thinking about it clearly enough at the moment.)
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    Quickly looking in XenForo_Phrase doesn't show anything that seems to allow run-time modifications besides adding to the params (done in code regardless) that'll allow variables in the phrases.
     
  3. xf_phantom

    xf_phantom Well-Known Member

    PHP:
    XenForo_Phrase::setPhrase('my_phrase_name''The new phrase value');
    BUT this will work probably ONLY in the php scripts, because the phrases in the templates are already compiled into the template.

    You'll probably need to use the post_render event and replace the old phrase value with the new one
     
    Jeremy likes this.

Share This Page