Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Get URLSegment by page ID

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

Page: 1
Go to End
Author Topic: 3789 Views
  • Pigeon
    Avatar
    Community Member
    243 Posts

    Get URLSegment by page ID Link to this post

    Hi everyone,

    I was just wondering if there is a nice clean way of getting the URLSegment (or the whole URL) for a page by parsing just the ID of the page? (i'm talking in the Page class

    not the template - but to use in the template too)

    I know i can do:

    DataObject::get_by_id('Page',$id)->URLSegment();

    But is there a function like:

    Page::getURL($id);

    Any help is much appreciated.

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Get URLSegment by page ID Link to this post

    Check the SiteTree.php for any function which gets the url but I doubt it exists. A DataObject::get_by_id() function will work just as easily.

  • Pigeon
    Avatar
    Community Member
    243 Posts

    Re: Get URLSegment by page ID Link to this post

    Cheers for the reply,

    There only seems to be:

    SiteTree::get_by_url($this->URLSegment, $idFilter)

    Cheers anyway

    3789 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.