adrian Posted June 8, 2023 Share Posted June 8, 2023 Thanks @MarkE - that's basically what I had to do. The difference however is that when hooking on saveReady for a just cloned page, the id is 0 even though it is a valid page and not a null page. Link to comment Share on other sites More sharing options...
froot Posted November 23, 2023 Share Posted November 23, 2023 how would make a custom page class for the template basic-page ? basic-pagePage? Basic-pagePage? Basic-PagePage? Link to comment Share on other sites More sharing options...
bernhard Posted November 23, 2023 Share Posted November 23, 2023 BasicPagePage.php class BasicPagePage extends Page { ... } You take whatever template name you have and convert that to camelcase, eg basic-page = BasicPage, foo-bar = FooBar, home = Home and then you add the suffix Page to that name (FooBarPage, HomePage). In case of BasicPagePage it sounds a bit weird and I've myself done that wrong several times when I forgot the suffix and just called it BasicPage.php and wondered why it is not working. But once you get the concept it's easy and makes sense ? 2 Link to comment Share on other sites More sharing options...
da² Posted December 8, 2023 Share Posted December 8, 2023 Damned, I have always thought that custom page classes were usable only in template.php files. ?♂️ This evening I wanted to hack PW to create a template/CustomPageClass mapping usable everywhere with PW API (get, find, etc), and in the first 3 minutes I found it was already there. ? This is huge, I love it and am already refactoring some code and twig templates with a custom UserPage, using Traits to share some implementation with my RawUser class (an optimized class from direct database query). I'm quite excited! ? 4 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now