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   1286 Views

Avatar
DeklinKelly

Community Member, 197 Posts

3 February 2011 at 4:15am

Edited: 03/02/2011 4:15am

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

Community Member, 279 Posts

3 February 2011 at 9:19am

$HomeLink = Director::absoluteBaseURL();

Avatar
DeklinKelly

Community Member, 197 Posts

3 February 2011 at 10:44am

Thanks!