Value returned by getCollectionPath() not working when Pretty URLs are not enabled

Permalink
I am getting a page path by ID like below:

$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?

BlueFractals
 
Remo replied on at Permalink Best Answer Reply
Remo
That's fine! The method shouldn't be used for that..
<?php
$nh = Loader::helper('navigation');
echo $nh->getLinkToCollection($p);
// echo $nh->getLinkToCollection($p, true);
?>


The second one would return the absolute URL.