Model or Method for all Page Objects

Is there any way to create a global model for all Page objects?..
or Is there any way to add a method for all Page objects as the same way as the fields??

I don’t know, maybe something like:

page::$methods['myMethod'] = function($page) {
    // ...

So I could run the method directly for the page instance: $page->myMethod()

Yes, but not as elegant as it could be:

  1. Create a plugin with your custom base class in it (just like a model), let it extend Page and name it however you want.
  2. Create a model for every template, but let it extend your custom class instead of Page.

oh! :frowning:

This is just what I don’t want to do, As you says, This is not so elegant especially because I have a lot of different kind of Pages.

This feature has been requested a few times now, so maybe it will find its way into the core in an elegant way. :slight_smile:

1 Like

I would love to have this feature, too.

1 Like

+1 —I’ve been looking for a way to do this as well

1 Like

There is a github issue for this one now as well: