Hi,
I am making a portfolio site. I want to have one single archive in the panel of all projects, with the option of 3 templates:
design, writing, and writingDesign
I want to load the content from the archive respectively onto two project pages.
The two project pages are:
One called Writing that loads writing and writingDesign projects,
One called Design that loads design and writingDesign projects,
I am currently working with a section called archive, but am having trouble loading content onto those two pages (writing and design)…
Should I be using collections? I know this should be possible. Basically I want to avoid duplicating projects in a writing and design section, since some of the content overlaps.
Hope that’s enough information to get guidance, thanks!
An your writing and design page, you filter the pages or the archive page by template, for example:
$writings = page('archive')->children()->filterBy('intendedTemplate', 'in', ['writing', 'writingdesign']);
Replace archive with the real name of your archive page or use the uuid instead.
And yes, you can do this in a collection instead of in your controller or template.
Is the above code recommended for a controller doc? And by “intended template”, you mean?
This is my file structure, if I can keep using a section, I’m fine with that, will only change to a collection if needed.
I think you are mixing up things here.
The function of a pages section is to create pages via the panel. So you create a pages section inside a pages blueprint (or include a separately defined section in a page blueprint).
The function of a collection is to create pages collections mainly for output in your templates.
So, then I can just keep it how I have, section, and not dabble in collections. I can do what I’m intending with my current page structure?
And in the above code you recommended, is that for a controller, by “intended template”, you mean?
Yes, controller or template, but I’m currently assuming that all your design, writing, and writingDesign subpages are children of one parent page called archive
Correct yeah, and I want to create a page called Writing that only prints out the subpages related to writing; and a page called Design that only prints out the subpages related to design.
In the pages section on those writing and design pages, you can then use the templates prop to filter by template, and set the parent to archive, see page section documentation
thank you this is working now, so helpful