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

Filtering content in template

Discussion in 'XenForo Development Discussions' started by AnthonyT, Nov 18, 2011.

  1. AnthonyT

    AnthonyT Member

    Hi everyone,

    I’ve developed an Add-On using the template_hook code event listener.
    My purpose is to filter the content of some templates in certain parts of the website. I did it almost everywhere I need, except for two places “Recent Activity” and “Postings” on the Member profile page.
    To access the text inside the template I’m using the following syntax :

    public static function template_hook ($hookName, &$contents, array $hookParamsXenForo_Template_Abstract $template)
    $hookName == “my_template”$contents filter($contents)

    The problem in these cases(“Recent Activity” and “Postings”) is that changing the $content variable the templates don’t change so I don’t know how to change the relative content

    Can anyone help?

    Thanks in advance
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  3. AnthonyT

    AnthonyT Member

    Thanks Jake,

    The post you suggested is very useful specially after spending most of my time finding the right hook :) but my current problem is to find the container variable not the hook.
    I've tried to filter everywhere regardless the hook and it works fine except for the locations I told you on my post : “Recent Activity” and “Postings” on the Member profile page so I guess I’m using the wrong one for that particular template .
    When I do the following

    public static function template_hook ($hookName, &$contents, array $hookParamsXenForo_Template_Abstract $template)
    $contents filter($contents// it filter everywhere
    My content is filtered in every place but the tabs in object. My question is :
    Is $content the right variable to filter?
    Is there any other variable which contains the data?
    I attach a couple of screenshots to explain you clearly.
    The first one is an example if filtered content while the others are not filtered

    Attached Files:

Share This Page