Closed thejame closed 5 years ago
Using {% set podcast_collection = page.collection( {'items':{'@page':'/sermons'} ) %}
gives me a collection to work with in the template, but I need to be able to send a different collection of items/pages to another podcast and would prefer to keep the template count low.
You've got a subtle error in your page header. For your use case, items
should contain a key-value pair, rather than a string. The twig snippet in your second comment actually shows you doing it this way!
...
content:
items:
'@page': '/sermons'
...
Thanks, and I have tried that. It produces a completely blank page - no errors or anything on my rendered XML template output. What's even more weird is if I create a html.twig template I get site data and not page data, and if I create an xml.twig template I get a totally blank page.
I think it's the double : in the line - maybe it doesn't like having more than one unescaped colon?
@thejame, there shouldn't be two colons in a line in the YAML front matter; the key-value pair goes on its own line (as in my code snippet above).
Thanks @N-Parsons, I understand the reasoning, but I am still not getting anything back using your proposed method. Either the list is blank or the page is blank. If you call items from another page in another folder, @page
should work, right?
Update: I took some code that wasn't even referencing the page collection out of the template and now it renders with the Markdown file. Thank you for the heads-up with the key-value pair rules - that was super helpful to know.
Try as I may, I cannot populate a collection with this page. Note that the page does not have any children (it's pulling the collection from another pages), and if I explicitly define the collection's content in the template it will bring back the data, but I need to fill the collection dynamically as I have several pages.
template (templates/podcast.html.twig):
page (pages/podcasts/podcast-a/podcast.md):
Thanks!