Patrik97 Posted June 30, 2020 Share Posted June 30, 2020 Since i am using Repeaters in nearly every project, i would like to know if i could use PageClasses with Repeater Pages. The repeater template is called: " repeater_files"; I tried class RepeaterFilesPage extends Page { and class RepeaterFilesRepeaterPage extends RepeaterPage { both aren't working. I changed the filename to the classname in both cases. Also what do you think about using PageClasses as Models and doing data related operations only through them? Link to comment Share on other sites More sharing options...
kixe Posted July 1, 2020 Share Posted July 1, 2020 @Patrik97 Welcome to the forum. RepeaterPageArray object represents the value of a repeater field, related to the page where the repeater lives in. A single item of this PageArray is an instance of class RepeaterPage. The class is set via FieldtypeRepeater::getPageClass(). This value is not changeable, the function not hookable. If you want to use a custom class for your repeater item objects with additional methods or properties, you need to create your own Fieldtype, derived from FieldtypeRepeater which includes your custom class and overwrites the getPageClass() function. Example where exactly this is done: FieldtypeRepeaterMatrix Maybe related: https://processwire.com/docs/tutorials/using-custom-page-types-in-processwire/ https://processwire.com/blog/posts/pw-3.0.152/#new-ability-to-specify-custom-page-classes https://processwire.com/talk/topic/20593-pageclasses-and-php-classes/ 1 Link to comment Share on other sites More sharing options...
BillH Posted July 1, 2020 Share Posted July 1, 2020 Hi @Patrik97 It might be worth you saying what you're trying to achieve. The kind of approach you describe would only rarely be necessary, though you may have particular needs. I'm wondering if there might be a much easier way of doing things. 1 Link to comment Share on other sites More sharing options...
Patrik97 Posted July 1, 2020 Author Share Posted July 1, 2020 Thank your for your replies. As allotted to in the last sentence of my post i would like to use the Page classes as Models (as you would in an MCV framework) and the template files as controllers. It seems to me like this would greatly improve the overall Project strucutrure. Also i think testing should be way easier through theese page functions rather than url calls. Link to comment Share on other sites More sharing options...
BillH Posted July 2, 2020 Share Posted July 2, 2020 Just my personal view, but PW isn't an MVC framework, so trying to make it behave like one doesn't really sound like a good plan. My guess is that you'd end up making things very difficult for little benefit. I'd suggest going about projects in a PW-like way unless there's a particular reason not to. For testing, there are lots of tools out there, e.g. https://www.cypress.io/, and you might find this module useful: https://modules.processwire.com/modules/process-nette-tester/ And I'd strongly recommend this module: https://modules.processwire.com/modules/tracy-debugger/ 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