Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Automatic URL manipulation via header.routes.default

Solved by Bernd Herbig View solution

Started by Bernd Herbig 9 years ago · 1 replies · 718 views
9 years ago

Hello together,
I would like to remove the /folder/ part from the url. (The parent folder)
I wrote
header.routes.default:
type: text
autofocus: true
style: vertical
label: Meine URL
default: "/"
into the system/blueprints/pages/default.yaml and it works fine.

Now, I would like to create or save the page and the header.routes.default should be written automatically into the default . md and especially it should be written default: "/foldername"

So I wouldn't need a extra field on my content area and it wouldn't be written manualy.

Thank you in advance.
Best regards
dci

9 years ago Solution

Hello,
I believe, I solved my issue by myself.
On the file system/src/Grav/Common/Page/Page.php I expanded the function frontmatter.
$this->frontmatter = (string)$var."routes: \n default: /".preg_replace(PAGE_ORDER_PREFIX_REGEX, '', $this->folder);
works fine for me.
Sure, I shouldn't work on /system/src ... but what should I do?
I think it would be more comfortable, if I could set it folder by folder (functionality like home-folder) via true or false on the admin panel.
dci

Suggested topics

Topic Participants Replies Views Activity
Support · by blu3prince, 4 days ago
1 68 4 hours ago
Support · by complanar, 7 days ago
6 157 2 days ago
Support · by Rick Beebe, 7 days ago
2 116 3 days ago
Support · by alex, 5 days ago
2 101 4 days ago
Support · by Marcel, 2 weeks ago
1 152 4 days ago