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

How to get a route including modular page folder name?

Started by Muut Archive 9 years ago · 1 replies · 621 views
9 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!

9 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 Deleted User, 9 years ago
0 2555 9 years ago
Archive · by Muut Archive, 9 years ago
2 1684 9 years ago
Archive · by Muut Archive, 9 years ago
2 4972 9 years ago
Archive · by Muut Archive, 9 years ago
1 3796 9 years ago
Archive · by Muut Archive, 9 years ago
3 1795 9 years ago