Open Perlkonig opened 6 years ago
that does seem odd, path()
should be the physical path of the page object, that really shouldn't change.
Thanks for looking into it. Linking with my plugin's issue: https://github.com/Perlkonig/grav-plugin-table-importer/issues/15.
I've tested this and things are working as expected. I suspect that it's simply a case of you using $this->grav['page']
as this is the overall page that is rendering (per the route requested). I created a test case where i looped over a collection:
<h3>Manual Initiated Collection</h3>
{% set options = { items: {'@page.children': '/core/issues'}, 'limit': 5, 'order': {'by': 'date', 'dir': 'desc'}, 'pagination': true } %}
{% set collection3 = page.collection(options) %}
<ul>
{% for p in collection3 %}
<li>{{ p.title }} - {{ p.path() }}</li>
{% endfor %}
</ul>
And the path printed was the expected path of each page in the collection.
OK, but in this case it's a shortcode. ShortcodeInterface doesn't have any capability of getting additional context. If $this->grav['page']
doesn't point to the actual page the shortcode is processing, what else can I use?
No additional information?
I'm not getting any pick up on Discourse, so I thought I'd try here.
My table importer plugin creates a shortcode that pulls data from the page’s folder (where the
.md
file lives). It does this by looking at$this->grav['page']->path()
. The problem is that when the page’s content is generated by the blog main page (as a preview),$this->grav['page']->path()
points to the blog’s main page and not the individual post. The summary is pulled in as you would expect:But again, when the shortcode processes the child page,
path()
returns the parent page's path. How can I rectify this? I’ve been pouring over the API documentation, but nothing’s jumping out as the answer.