Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Pulling content from different pages?

Started by Muut Archive 11 years ago · 1 replies · 259 views
11 years ago

Hi guys, have enjoyed playing with Grav this weekend and gotten quite far in converting an existing website I have.

One issue I have though -- I have item pages, let's say "cars" .. so /car/ford, /car/volvo etc. each with their own item.md ..

How would I go about creating comparison pages for these? Is it possible without a plugin? .. ie:

/cars/comparisons/volvo-vs-ford or /car/comparisons/volvo/ford .. I imagine having a Twig template that gets the two last slugs from the url segment and then grabs the data based on that.

11 years ago

You can use the find() method of the Page object to load another page. For example:

TWIG
{% set ford = page.find('/car/ford') %}
<div id="ford-content">{{ ford.content }}</div>

More details in the docs

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1322 9 years ago
Archive · by Muut Archive, 9 years ago
2 918 9 years ago
Archive · by Muut Archive, 9 years ago
2 4048 9 years ago
Archive · by Muut Archive, 9 years ago
1 2922 9 years ago
Archive · by Muut Archive, 9 years ago
3 1106 9 years ago