Where do I put the code to extend the page model?
You can read more about page models in the docs.
Absolutely. Read all that and don’t get it. Thanks for the reply, though.
Well, let’s say the template of the page you want to extend is site/templates/contact.php
. The model for that template is site/models/contact.php
.
What you need to do is to create that file, put the class definition in it and define the methods you want to have available in your template. In this case the method is rootParent()
. The code that runs after you call the method is defined in the model method.
Let me know if you have any further questions.
In this case, I am specifically trying to implement the solution in the forum for returning the root parent. I just don’t know how to use the code given. I am not able to use $page->parent() if the current page is a top-level page. So I’m trying to extend the default page model.
How does your full page model look like after you copied in the code from the forum post?
Thanks again for your help. I may be tackling this the wrong way, so I’m going to post a new topic with my specific question and code.