Override next_previous block controller

Hello, I'm trying to override the block next_previous's controller with my own replacing some functions.
use \Concrete\Block\NextPrevious;
class Controller extends NextPrevious {

My file is in application/blocks/next_previous/controller.php

I need to override view, getNextCollection and getPreviousCollection for my custom template as I need to be able to pass a page into the next and previous methods so that I can get the parent page's next and previous page.

When I try this it just throws the error "Class 'Concrete\Block\NextPrevious' not found" which I'm assuming that my controller is trying to load before the actual controller.

Is there a better way to override the block controller's functions?

View Replies:
hutman replied on at Permalink Reply
I'm not sure if this is the "right" way, but you can copy the entire /concrete/blocks/next_previous/controller.php into your /application/blocks/next_previous/controller.php and the update the namepace and the site will use that controller rather than the one in the concrete folder.
hdocwra replied on at Permalink Reply
That's a good idea actually.

I ended up making my own package with a new replacement next previous block under a different name.

Namespaces are annoying and I'm not too great with them in php.
andrew replied on at Permalink Reply
That is true; just an FYI, the namespaces are a bit off in this forum post.

1. Disable overrides cache in the dashboard.
2. Copy concrete/blocks/next_previous/controller.php to application/blocks/next_previous/controller.php
3. Delete everything in application/blocks/next_previous/controller.php, and add this code:

namespace Application\Block\NextPrevious;
use Concrete\Block\NextPrevious\Controller as CoreNextPreviousController;
class Controller extends CoreNextPreviousController

Then, anything you put in there will override the original block controller.

And also – creating your own block for this is a very good solution as well.