Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. 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 · 750 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 webmasterodp, 6 days ago
4 143 5 days ago
Support · by nwhitfield, 1 week ago
2 122 1 week ago
Support · by stell, 2 weeks ago
5 363 2 weeks ago
Support · by gravinator, 1 month ago
5 554 2 weeks ago
Support · by Gravver, 3 weeks ago
6 344 3 weeks ago