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 →

How to get a route including modular page folder name?

Started by Muut Archive 10 years ago · 1 replies · 702 views
10 years ago

In a plugin, I'm trying to find a page using a route which is made up of slugs. For example: /assignments/drafts.

The challenge here is that the page "Drafts" is a modular page and therefor it's folder name is _drafts.

$this->grav['page']->find('/assignments/drafts') fails but obviously $this->grav['page']->find('/assignments/_drafts')will succeed.

Is there a built in function that will convert a route containing modular pages to an "expanded" version which includes the underscores?

Many thanks!

10 years ago

Uh, I think not. Both above routes are valid and both pages (one being a normal page and the other being of type modular) may even co-exist as childs of the same parent. In other words their folders, named drafts and _drafts respectively, may exist within the same folder.
When these pages exist the Page find() method will find them both.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Muut Archive, 10 years ago
1 672 1 week ago
Archive · by Deleted User, 9 years ago
0 3042 9 years ago
Archive · by Muut Archive, 9 years ago
2 1983 9 years ago
Archive · by Muut Archive, 9 years ago
2 5336 9 years ago
Archive · by Muut Archive, 9 years ago
1 4134 9 years ago