Hi - I saw a much older post which I though might address this (merging collections into an array) but doesn’t seem to be working for me.
I have figured out how to display the tagged page from one folder (artworks3) this is the code I am using for that:
(This has a checkbox for ‘private’ in the blueprint)
<?php
if ($artworks3Page = page('artworks3')): ?>
<?php foreach ($artworks3Page->children()->listed()->filterBy('category', 'private') as $artwork3): ?>
What I want to do is display all the pages (tagged ‘private’) from several folders (artworks1, artworks2, artworks4, etc…)
How would I do this?
Many thanks.
These pages are all on the first level, I assume? Do they share the same template/blueprint?
Assuming these pages all use a template artworks
:
$artworkPages = $pages->template('artworks');
$privatePages = $artworkPages->children()->filterby('category', 'private');
Hi - yes they are all on the first level - but at the moment all have their own template and blueprint (because I haven’t quite figured out how to do the sharing thing yet!!)
Can it be done the way I have it currently set up, or do I have to figure out the shared blueprint/template way? (In which case - major help needed please!!)
Why do they all have a different blueprint? And why are they all first level pages instead of subpages of an artworks
first level page?
But yes, you can do it also with your current setup:
$privatePages = $pages->children()->filterby('category', 'private');
Perhaps I am using the terminology incorrectly my apologies - the current folder set up is:
Content (folder)
—>1_artworks1 (folder)
—>--->1_artwork_name (folder)
—>--->—>artworks1.txt
—>--->—>artwork_name_x.txt
—>--->—>artwork_name_x.jpg.txt
—>--->2_artwork_name (folder)
—>--->—>artworks1.txt
—>--->—>artwork_name_y.txt
—>--->—>artwork_name_y.jpg.txt
—>2_artworks2 (folder)
—>--->1_artwork_name (folder)
—>--->—>artworks2.txt
—>--->—>artwork_name_z.txt
—>--->—>artwork_name_z.jpg.txt
—>--->2_artwork_name (folder)
—>--->—>artworks2.txt
—>--->—>artwork_name_a.txt
—>--->—>artwork_name_a.jpg.txt
Reason they are using different blueprints is I am still learning how to share a blueprint and haven’t managed to get it working yet - so I am sure I will need further help to do that!
In your code:
$privatePages = $pages->children()->filterby(‘category’, ‘private’);
is $pages getting ALL pages in the site? Is that how it works?
Thanks!
$pages
gets all first level pages, i.e. those directly under /content
.
Your folder structure looks a bit weird, as if you had stray txt files that don’t belong to anything while on the other hand text files are missing.
But do you get the correct pages with the code I suggested above?
The extra text file seems to get generated when I fill in the image caption and alt text -
Is that the text file you mean?
Yes, but that’s fine if the image file exists… I couldn’t see that from what you posted above.
And… it works perfectly!! My goodness, thank you so much for helping.
If these pages all have the same content structure, consider using the same blueprint, i.e. artworks.txt
for the top level artworks, and artwork.txt
for the children.
Yes, that is my next challenge - I am duplicating blueprints and templates which I know is silly - but I now have the functionality working for exactly what I need so I can calmly try to figure that out!
Thanks so much again.