tldr: How can I call the entire content of all pages with page collections?
I’m new to grav and my php skills are quite limited. However I have already built a couple of websites with another flat file cms and wanted to try out grav and I like it so far.
I’m trying to build a onepager portfolio site with a straightforward content structure. There will be 10-15 projects each with 5 custom fields and some images. However there is a lot of content and so I thought, the modular page approach is not the right one. Please correct me, if I am wrong here.
I wanted to build a page for each project, and then call all project-pages on one page with Page Collections.
{% for p in page.collection %}
{{ p.content }}
{% endfor %}
only outputs the content of the homepage, {{ p.title }} works though.
This is how I use Page Collections in the frontmatter of the homepage.
content:
items: '@self.siblings'
How can I call the entire content of all pages with page collections? Or is it the wrong approach to build pages first?
@luap, Without knowing your folder structure, the above snippets looks OK at first sight.
At first I thought it might be an issue of ‘sibling’ vs. ‘descendants’, but that doesn’t match your remark that {{ p.title }} works and {{ p.content }} does not…
To be sure, I tried your code as follows:
Using a fresh installation of Grav 1.6.22, using theme Quark
Thanks for the answer! It was a misunderstanding on my side.
I was hoping content was calling the entire content of an page, like defined in my project.twig, but that didnt work.
So I have to call each custom field like I did in the project.twig file, but that’s okay!
Looks like this now and works
{% block content %}
{% for p in page.collection %}
<h3>{{ p.title }}</h3>
{%- if p.header.entext %}
{{- p.header.entext|markdown -}}
{% endif -%}
{%- if p.header.detext %}
{{- p.header.detext|markdown -}}
{% endif -%}
{%- if p.header.credits %}
{{- p.header.credits|markdown -}}
{% endif -%}
{% endfor %}
{% endblock %}