Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Page paths and child collections

Started by Aaron Dalton 9 years ago · 1 replies · 838 views
9 years ago

My table importer plugin 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:

PHP
    {% for child in collection %}
      {% include 'partials/blog_item.html.twig' with {'page':child, 'truncate':true} %}
    {% endfor %}

How can I rectify this? I've been pouring over the API documentation, but nothing's jumping out as the answer.

9 years ago

You could put an if condition around your include, that pulls the data like it does now for each blog item, when not on the mainpage. If on the main page however try going pulling it from another layer? Might not work but I think that's the way to go

Suggested topics

Topic Participants Replies Views Activity
Plugins · by renedebaaij, 6 hours ago
0 10 6 hours ago
Plugins · by complanar, 2 weeks ago
6 377 2 weeks ago
Plugins · by BenLaKnet, 2 weeks ago
1 194 2 weeks ago
Plugins · by complanar, 1 month ago
2 471 4 weeks ago
Plugins · by Vladimir Novak, 2 months ago
3 749 2 months ago