Get $page's content folder

#1

Hey there,
lets say I got a page under content/3_somepage/subpage/mypage.txt. I want to get its path starting in content, eg 3_somepage/subpage/ - I checked the dump of $page, but for one, the numbered parent always appears without its number, and if the folder has a number (date string), I dont get that, too …

Help please!

:slightly_smiling_face:

// Edit:
What I got so far is this: $kirby->root('content') . '/3_somepage/' . $page->num() . '_' . $page->slug(), but that doesn’t work for drafts …

#2

Hm, $kirby->root('content') starts at the root, but you said you wanted it to start with content. There is not direct method. This starts at content:

<?php dump('content/'.$page->diruri()) ?>

If you need it more often, you can create a custom page method.

#3

diruri, never heard of that one, thx alot!

#4

Look at https://getkirby.com/docs/reference/objects/page/diruri for Kirby3.