Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Problem with shortcodes in subpages

first-time

Started by ptrxyz 6 years ago · 2 replies · 734 views
6 years ago

I am looping over a page's subpages using {% for p of page.collection %} and then dump the shortcodes using
{{ dump(p.contentMeta.shortcodeMeta.shortcode) }} .

The dump of the shortcode object always contains the values of the very first subpage (while p.raw_content is correct). I think that's ... wrong. Or am I doing it wrong? I would assume, that p.contentMeta.shortcodeMeta should always be the shortcodes of the page that p refers to.


So as an example, if I have three subpages, each one containing this (with an increasing number for example):

TXT
[section name="text"]This is from subpage 1[/section]

and my main page looks like this:

TWIG
{% for p in page.collection %}
{{ dump(p.contentMeta.shortcodeMeta.shortcode.section.text) }}
{% endfor %}

the output is

TXT
This is from subpage 1
This is from subpage 1
This is from subpage 1

instead of

TXT
This is from subpage 1
This is from subpage 2
This is from subpage 3

which is what I would expect...

I am super new to this whole Twig world, am I doing it wrong? Any help would be appreciated. 🙂

6 years ago

@ptrxyz, I can reproduce the issue and added a reproducible test case to the issue you submitted at the repo of 'grav-plugin-shortcode-core'

👍 1
6 years ago

Thanks! I hope we can fix this at some point.

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 1 day ago
2 42 20 hours ago
General · by Hanns Mattes, 1 week ago
0 123 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago