Controller, router and me.


Active member
I have asked a similar question before but I still haven't found a good solution so far.

For my add-on I am currently using 2 PublicControllers, each with a separate route.

The url structure looks like this: (index, with all bookshelves) (bookshelf, id1) (bookshelf, id1) (index, with all books) (book, id1) (book, id1)

That's totally fine (for now) but I have one big problem: There is no way to display all bookshelves by user X.
This would require an url structure like (or similar)

With my current setup, it asks me for an action 'Member1' when want to open a link like this.

I am implementing the XenForo_Route_Interface, this is my method:
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router) {
        $action = $router->resolveActionWithIntegerParam($routePath, $request, 'book_id');
        return $router->getRouteMatch('Doh_Books_ControllerPublic_Book', $action, 'book');


What do I have to change to be able to use


Thanks for your help. :)
The resolveActionWithIntegerParam method (and the converse version for link building) is really just a helper method. If you want to do something more complex (which this would fit under), you will have to do more low level structural parsing. (There are a few places we have done this, but usually it's just a pain.)

Though as an aside, what about members/1/bookshelf?
Thanks Mike, I will take a closer look at the XenForo code. :)

members/1/bookshelf sounds good, too. Can this be done without breaking the default routing that handles the member stuff?
Yeah, it's really setup for it already. You just need to use load_class_controller to extend the Member controller for your action.
Thanks Mike, it's working like a charm. :)

Here's what I did:
I created a new code event listener that listens to 'load_class_controller'.

The execution callback is: Doh_Books_Listeners_LoadClassController::loadClassListener

My listener (library/Doh/Books/Listeners/LoadClassController.php) looks like this:
class Doh_Books_Listeners_LoadClassController
     * @static
     * @param  $class
     * @param  $extend
     * @return void
    public static function loadClassListener($class, &$extend)
        if ($class == 'XenForo_ControllerPublic_Member')
                $extend[] = 'Doh_Books_ControllerPublic_MemberBook';

As far as I can see, I need the separate controller for this because otherwise it is going to overwrite the Member controller with all actions from my main controller.
I'm sorry to be posting, but I actually laughed at the title of this thread. :) +1!
Top Bottom