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

I get an error with this listener

Matthew Hawley

Well-known member
#1
Im trying to create an addon and I'm getting an error with this listener. What's wrong with it?
This is from http://xenforo.com/community/resour...-insert-tabs-in-profile-page-using-hooks.335/
Code:
<?php
//Look! The name of the class follow our directory structure!
//nameOfTheAddon_File (without the ".php" for sure!)
//This can be: nameOfTheAddon_Folder_File or nameOfTheAddon_Folder_Folder_File
class findPostsInThread_Listener
{
    //Our callback signature! We are using here! Look:
    public static function template_hook ($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        //Yey! its our template hook!
        if ($hookName == 'thread_view_pagenav_before')
        {
            //Our tab! We will do somethin better, hang on.
            $contents .= '<label><a href="{xen:link search/search, '', 'type=post', 'thread_id={$thread.thread_id}', 'users={$visitor.username}'}">Your Posts</a></label>';
        }
    }
}
?>
 

Jeremy

Well-known member
#3
PHP:
            $contents .= '<label><a href="{xen:link search/search, '', 'type=post', 'thread_id={$thread.thread_id}', 'users={$visitor.username}'}">Your Posts</a></label>';
should be
PHP:
            $contents .= '<label><a href="{xen:link search/search, \'\', \'type=post\', \'thread_id={$thread.thread_id}\', \'users={$visitor.username}\'}">Your Posts</a></label>';
You need to escape the single quotes found within the quote, or you build an invalid string, causing the syntax error you are receiving.