Value returned by getCollectionPath() not working when Pretty URLs are not enabled
Permalink
I am getting a page path by ID like below:
In my localhost, $page_path contains the path like "/mysite/about".
This works fine when Pretty URLs are enabled but does not work when it's disabled.
How do I get the path returned by getCollectionPath() so that if Pretty URLs aren't enabled it looks like this: "/mysite/index.php/about/". Is there a way to dynamically have getCollectionPath() return a value based on whether or not Pretty URLs are enabled?
$p = Page::getByID(20); $page_path = DIR_REL.$p->getCollectionPath();
In my localhost, $page_path contains the path like "/mysite/about".
This works fine when Pretty URLs are enabled but does not work when it's disabled.
How do I get the path returned by getCollectionPath() so that if Pretty URLs aren't enabled it looks like this: "/mysite/index.php/about/". Is there a way to dynamically have getCollectionPath() return a value based on whether or not Pretty URLs are enabled?
The second one would return the absolute URL.