Jump to content

leode

Members
  • Posts

    2
  • Joined

  • Last visited

leode's Achievements

Newbie

Newbie (2/6)

0

Reputation

  1. Yes, other methods fro custom page types work fine.
  2. Hello Guys! I read the article https://processwire.com/blog/posts/pw-3.0.152/ and want to add some custom methods to all of my pages. As I understand, when I add /site/classes/DefaultPage.php with class DefaultPage extends Page {} and put in my properties and methods, they should be available to all pages. Here is the code I tried: <?php namespace ProcessWire; class DefaultPage extends Page { public function test() { return 'test'; } } However, this does not work (Exception: Method ArticlePage::test does not exist or is not callable in this context) page()->get('/mytestpage/')->test() I would have guessed that since HomePage extends Page and all Page instances are now DefaultPage, my test() method would work. Is there no other way than using hooks to add custom methods to have them on all pages (HomePage, basic-page, my custom ones, etc.)? Thank you for your help!
×
×
  • Create New...