Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Problem with shortcodes in subpages

first-time

Started by ptrxyz 6 years ago · 2 replies · 633 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 Old Man Umby, 1 week ago
2 114 3 hours ago
General · by jeremycherfas, 2 weeks ago
5 202 15 hours ago
General · by lynbor, 6 days ago
2 133 4 days ago
General · by Sebastian, 2 weeks ago
1 132 2 weeks ago
General · by Andy Miller, 3 weeks ago
0 256 3 weeks ago