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

Addon for forum_list template

#1
Hey guys,

I already created an addon for a custom page.
For this addon I stored my php files under /library/Pages/addon.php (php class stuff) and /library/Pages/addonCode.php (the main php code). I call this addon by using {raw:addonblabla} .... there are no problems, it works perfect.

Now I would like to create a "last activity addon" that I can include above the forum in the forum_list template. But it doesn't work. When I call my new addon in the named template, nothing happens. Do I have to store the php files in another directory or what's the problem?
 

Arik

Well-known member
#2
It's not directory specific, so as long as your class names are set up correctly, that shouldn't be a problem.

Post your code, there's likely a problem in there somewhere.
 
#3
Okay,

let's start from the beginning.

I created a file called newActivity.php in /library/XenForo/Pages/
That's the code of the file:
PHP:
<?php
class newActivity
{
    public static function includeFile(XenForo_ControllerPublic_Abstract  $controller, XenForo_ControllerResponse_Abstract &$response)
    {
        ob_start();
        include('newActivityCode.php');
        $newActivity = ob_get_contents();
        ob_end_clean();

        $params = array(
            'newActivity'  => $newActivity
        );

        $response->params = array_merge(
            $response->params,
            $params
        );
    }
}
Now I created a new Addon called New Activity and a Code Event Listener with the following configuration.
- Listen to Event: template_hook
- Execute Callback: newActivity::includeFile
- Addon: New Activity

Now I get the following error: "Please enter a valid callback method."
What's going on?
 
#4
Okay, new problem :)

Instead of using the library/XenForo/Pages directory I created a directory called library/newActivity and I renamed the main file to Listener. Now I can create my event Listener without problems (newActivity_Listener::includeFile).

But now when I visit my forum there's a LONG list of errors where I execute the newActivity-Hook. Here's the first one (I don't want to list them all):

Code:
Template Errors: forum_list
  1. Argument 1 passed to newActivity_Listener::includeFile() must be an instance of XenForo_ControllerPublic_Abstract, string given in /blablabla...../library/newActivity/Listener.php, line 4:

      3: $__extraData['h1'] .= htmlspecialchars($xenOptions['boardTitle']);
      4: $__output .= '
      5: