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

  • 1
  • Question
  • Updated 2 months 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

  • 422 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Pat Vachon

Pat Vachon, Champion

  • 44,426 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 Arne-Per Heurberg

Arne-Per Heurberg

  • 2,854 Points 2k badge 2x thumb
Hi Pat, any idea on how using the Master/Child pages for access to models as described would work the Page Include aspect that Mark references? (i.e. Child/Child page includes are problematic). I know in another post it was mentioned that a custom component was built to get model access to the included page from the main page. Thanks 
Photo of Pat Vachon

Pat Vachon, Champion

  • 44,426 Points 20k badge 2x thumb
Let's say that both the parent and child page had a model for an Account based on URL Param "id". Instead of creating a model in each page for the Account you could created it with only in the parent page and reference it the name of the model in the child by setting the model name via XML.

It would work as if the model existed and components all existed in one page Skuid page.
Photo of Arne-Per Heurberg

Arne-Per Heurberg

  • 2,854 Points 2k badge 2x thumb
Thanks! That is what I thought which , would be perfect (and avoid having to copying the model into include). You were clear on the XML manipulation. I thought we could access it through the Master/Child as you showed but then I haven't figured out how then to do the include as it either becomes recursive or child/page include child breaks. I notice you said parent here not Master. I feel like I am missing something massively obvious. I apologize ahead of time. 
Photo of Mark Tucker

Mark Tucker

  • 422 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 Pat Vachon

Pat Vachon, Champion

  • 44,426 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

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