Addon for forum_list template

Richey

Member
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?
 
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.
 
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?
 
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:
 
Ok, I finally was successfull .... after watching Kiers tutorial on how to create a hook/addon
Now my visitors can see the newest posts on my forums home: http://www.vfxboard.de
It's not final but it should be okay for now :)
 
Top Bottom