21294 Posts in 5734 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1801 Views |
-
Get link by ID for nested pages

16 January 2011 at 1:16pm
How can I get the link of a page by its ID?
This code only works if nested URLs are disabled. It does NOT work for nested URLs:
$Link = Director::BaseURL() . DataObject::get_by_id("SiteTree", $page->ID)->URLSegment;
-
Re: Get link by ID for nested pages

16 January 2011 at 3:29pm
Use the Link method rather than trying to build it with the URLSegment,
try:
$Link = DataObject::get_by_id("SiteTree", $page->ID)->Link;
-
Re: Get link by ID for nested pages

16 January 2011 at 3:42pm
Howard, that does not work. It does not provide a full actual link either. The URLSegment field in the SiteTree database does not contain the full url, only the URLSegment of the final child page. How can I get the FULL URL Segment as impacted by parent pages?
-
Re: Get link by ID for nested pages

17 January 2011 at 1:09am
$Link = DataObject::get_by_id("SiteTree", $page->ID)->Link();
should work
| 1801 Views | ||
|
Page:
1
|
Go to Top |

