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 →

URL to most recent page?

Solved by Justin Young View solution

Started by Justin Young 4 years ago · 3 replies · 707 views
4 years ago

I believe Login plugin does similar thing. IIRC, it has configurable route and if you navigate to that route, it shows the page. So instead of showing the page, you could grab the latest post and redirect.

4 years ago Solution

Thank you.

I think I can do it by using https://learn.getgrav.org/17/content/collections

Specifically, I created a page that will display the contents of the most recent page:

YAML
---
title: Most recent page
published: true
content:
    items: '@self.children'
    order:
        by: date
        dir: desc
    limit: 1
    pagination: true
routes:
    default: /recent
---

{% for p in page.collection %}
<h2>{{ p.title|e }}</h2>
{{ p.content|raw }}
{% endfor %}
last edited 03/10/23 by Justin Young
4 years ago

Great! If this solves your problem, don't hesitate to mark your own answer as a solution ;)

👍 1

Suggested topics

Topic Participants Replies Views Activity
General · by Karmalakas, 2 days ago
2 75 1 day ago
General · by Hanns Mattes, 2 weeks ago
0 166 2 weeks ago
General · by Dima, 3 weeks ago
1 164 3 weeks ago
General · by pamtbaau, 3 weeks ago
0 270 3 weeks ago
General · by lynbor, 2 months ago
5 755 1 month ago