Can a Child Page (via Page Include) use the Model of it's Parent?

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have found several posts related to this, but I feel like they are not getting at the exact nature of my question. I am wondering if an included page (child) can use the model of it's including (parent) page? The obvious goal here is to not have multiple (redundant) models in the page while benefiting from the modular nature of page includes. Hope this is clear.
Photo of Mark Tucker

Mark Tucker

  • 412 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
I think I understand your question. The answer is yes and no. The page builder ui doesn't have the models from the parent to reference, but you can manually alter the XML to achieve the desired result.

You can however make use of Master and Child pages where the models on the Master page is available to the Child Page. The models in the pic that are dimmed are from the Master page.

(Edited)
Photo of Mark Tucker

Mark Tucker

  • 412 Points 250 badge 2x thumb
Thanks for the quick response, Pat. So are you implying that when a parent page has, let's say the Account model, and the child also has Account, that the finished page will only leverage one model? Sorry if I'm reading into your explanation.
I'll try the XML approach as well. Thanks!
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Not really. The Account model on the parent page can be accessed by the child page if it indeed has been loaded into it.

Having an "Account" named model on both pages will likely lead to funky errors.

You can create the "Account" model on both pages the exact same, build the child page as you'd like, then you'd simply delete the "Account" model through the XML. Problem with this is that your components will easily break since the moment you click on them, the model selected while automatically grab the first from the drop down.

All this to say, you'd better a really really compelling reason to do this.

I otherwise suggest using the Master and Child page functionality that came with Banzai.
Photo of Mark Tucker

Mark Tucker

  • 412 Points 250 badge 2x thumb
OK, thanks a lot for the detailed responses!