Get site content folder on a site?

Hi all,

how to get the project content folder within a site?
Example:
$page->contentfolder()

returns:
content/pagetitle/site1/

You can either do $page->root() for the absolute path to the content folder for that page or $page->diruri() for something like pagetitle/subpagetitle

To fetch a page you can use the page() helper:


page('somepage/somsubpage')->diruri();
page('somepage/somsubpage')->root();

hello, thanks alot, it works!

Then what is the difference between these two?

$page->diruri()
$page->uri()

I got the same result when I tested them.

In the docs it can be helpful to also have an example of the output for dummies like me.

On the homepage of the demo content you get:
$page->diruri()= “home” (it is invisible! => no numbering)
$page->uri()= “home

On the page “Homepage › Projects › Project A” of the demo content you get:
$page->diruri()= “2-projects/1-project-a
$page->uri()= “projects/project-a

On the page “Homepage › Projects › Project B” of the demo content, if you have set the page “Project Binvisible, you get:
$page->diruri()= “2-projects/project-b
$page->uri()= “projects/project-b

In other words:
diruri() includes the numbering (due to sorting), if any.

Good luck!

1 Like

Thanks! I did not have the sorting on. Then uri for the template and diruri for working with the content folders.