Jump to:

22975 Posts in 11620 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Get link of home page

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

Page: 1
Go to End
Author Topic: 1073 Views
  • DeklinKelly
    Avatar
    Community Member
    196 Posts

    Get link of home page Link to this post

    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.

  • baba-papa
    Avatar
    Community Member
    279 Posts

    Re: Get link of home page Link to this post

    $HomeLink = Director::absoluteBaseURL();

  • DeklinKelly
    Avatar
    Community Member
    196 Posts

    Re: Get link of home page Link to this post

    Thanks!

    1073 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.