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

Template Hook: Can't Work Out What I'm Doing Wrong

Discussion in 'XenForo Development Discussions' started by James, Jan 20, 2012.

  1. James

    James Well-Known Member

    I think I just need a fresh pair of eyes because I can't find the problem at all, but here goes:

    public static function templateHook($hookName, &$contents, array $hookParamsXenForo_Template_Abstract $template)
    if (
    $hookName == 'message_user_info_text')
    $search '<h3 class="userText">';
    str_replace($search$search $template->create('UserImages_images'$hookParams)->render(), $contents);
    Why isn't my new template being displayed? The template "UserImages_images" does exist.

    EDIT: if I die(str_replace($search, $search . $template->create('UserImages_images', $hookParams)->render(), $contents)), it outputs fine, however when I return it, it doesn't display.
  2. Syndol

    Syndol Guest

    No need to return or render. $contents is passed by reference.
    $contents = str_replace($search, $search . $template->create('UserImages_images', $hookParams), $contents);
    James likes this.
  3. digitalpoint

    digitalpoint Well-Known Member

    Also, you should add to $contents, not replace it (in case other addons use the sage hook location).
    guiltar likes this.
  4. guiltar

    guiltar Well-Known Member

    Because other developer could already replaced the string you are looking for.
    You can just add your stuff before <h3 class="userText"> and use css to make it look as you want.
  5. James

    James Well-Known Member

    I'm not replacing the h3, I'm adding to it. Note the $search . $template.
  6. digitalpoint

    digitalpoint Well-Known Member

    Oops yeah... ignore me when it's like 1am, I can barely think. :)
    James likes this.

Share This Page