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

How to get a route including modular page folder name?

Started by Muut Archive 9 years ago · 1 replies · 492 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 1323 9 years ago
Archive · by Muut Archive, 9 years ago
2 920 9 years ago
Archive · by Muut Archive, 9 years ago
2 4048 9 years ago
Archive · by Muut Archive, 9 years ago
1 2924 9 years ago
Archive · by Muut Archive, 9 years ago
3 1106 9 years ago