Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Get link of home page


Reply

3 Posts   1201 Views

Avatar
DeklinKelly

3 February 2011 at 4:15am (Last edited: 3 February 2011 4:15am), Community Member, 197 Posts

What is the best way to get the full path to the home page?

This only works if the ID of the home page is 1:

$HomeLink = DataObject::get_by_id("SiteTree", 1)->Link();

But if I make a different page the home page it does not work.

Avatar
baba-papa

3 February 2011 at 9:19am Community Member, 279 Posts

$HomeLink = Director::absoluteBaseURL();

Avatar
DeklinKelly

3 February 2011 at 10:44am Community Member, 197 Posts

Thanks!