This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

InnerCode
InnerCode

Hi,

I want to use custom routes in my plugin. For example: backend/innercode/gallery => Displays a list of all galleries backend/innercode/gallery/1/photos => Displays al photos

The first route is no problem because the cms makes that route. The second however is a problem.

I created a routes.php file in the root folder with the route:

Route::get('backend/innercode/gallery/{gallery_id}/photos', 'Innercode\Gallery\Controllers\Photos@index');

It creates the following error: Call to undefined method Innercode\Gallery\Controllers\Photos::getAfterFilters() /home/innercode/Code/octobercms/vendor/october/rain/src/Extension/ExtendableTrait.php line 371

I can't find any documentation about this or using nested controllers.

How can I achieve this? Thanks in advance.

InnerCode

Last updated

vanderb
vanderb

Don't know if I'm too late for this, but simply add following code to your custom controller, and it should work

    public static function getAfterFilters() {return [];}
    public static function getBeforeFilters() {return [];}
    public static function getMiddleware() {return [];}
    public function callAction($method, $parameters=false) {
        return call_user_func_array(array($this, $method), $parameters);
    }

Last updated

nik.parotikov6522
nik.parotikov6522

Necro-bump :) I make gist for this: https://gist.github.com/parotikov/9449e62c18740596b669537715789f0f

Briefly:

  • you make a base controller, that extends october core frontend controller (Cms\Classes\CmsController);
  • you make custom controller, that extends your base controller (or, you can directly extends here october controller);
  • in routes you point to your custom controller action;
  • optionally, you can use route namespace parameter to short controller name;

Last updated

RomaldyMinaya
RomaldyMinaya

Hi,

Just add a routes.php file withing your plugin folder and it will load automaticaly, there you can put all the customs routes you'd like

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.