Hi, I’m trying to iterate through the pages within my section, but to do it within my section’s _index.md. I’m trying to use a shortcode for this, but it seems that the section context within the shortcode is not available.
When I debug with __tera_context I see some information from the section, but the pages variable is always an empty array. This isn’t the case if I debug the same way with the template.
I also tried to pass the section context as an argument to the short code, but it seems like there’s no section context at all within the markdown?
Is the only way to access a section’s context within the template itself?
You can access a slightly slimmed down version of the corresponding variables in the normal templates. The only things missing are translations, backlinks and pages for sections, as we are still in the middle of editing.
However, I haven’t found a bug entry for this on github. Is this really being worked on?
Hi @spence, thanks for the quick reply.
I also understood that this is not possible at the moment.
But is it now generally not possible? Then the documentation should be adapted,
or could this still be implemented, then the appropriate entry is missing in the Github issue.
Maybe I answered a little too quickly. Let me see if I understood your problem and question correctly.
First, let me just confirm that you are talking about accessing the .pages of a section, within a shortcode, right?
If that is the case, then no you can not do it, and it’s not a bug or something waiting to be implemented. I think that’s what you meant by “at this moment” vs “in general”. It’s just not how Zola works.
But is it now generally not possible? Then the documentation should be adapted,
I think where I’m confused is how should the documentation be adapted? To me that’s what it already says, but what should it say, from your pov?
Or maybe I’m mistaking you entirely. Feel free to let me know where I got confused.
It will probably be a misunderstanding on my part because English is not my first language.
I must have misunderstood the subordinate clause (
…, as we are still in the middle of editing.
), namely that the team is currently working on making it possible and not that Zola is working on the wrong place to make it possible.
That’s really hard for me to put into words.
But thank you, I realise now that it’s never going to work. So I have to find another way.
I agree with proofy, or that if you have to have it in there, the way you said it originally in this thread, I.e.
Rendering of markdown is done before populating the sections so that won’t be possible
is the best path to tidying up the intention in that part of the docs.
However
as we are still in the middle of processing
might be confusing to others. The questions of who “we” or is meant by “middle” or even “processing”. It may not be clear that the “we” is a program, and therefore in the “middle of processing” means the order that things were compiled and therefore what information is available at this step is limited.
So, something like
The following attributes cannot be used:
translations
backlinks
pages for sections
(Note: this is because the rendering of markdown is done before populating the sections)
would be crystal clear, if you wanted to keep the explanation in there.