Jump to:

23003 Posts in 11856 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » How to get full URL in 2.4

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: 2004 Views
  • theoldlr
    Avatar
    Community Member
    103 Posts

    How to get full URL in 2.4 Link to this post

    Hopefully this is an easy one that I just can't seem to find...

    If you are using hierarchical urls in 2.4 what function(s) would you use to get the full path. For example if you have yoursite.com/Parent/Child/Grandchild how would return the full path. I've been looking at Director functions, but I can only get them to return the beginning and the end of the full URL i.e. yoursite.com/parent or child/grandchild. I was using baseurl and urlParams respectively. What simple thing am I missing?--I want to be able to redirect to yoursite.com/Parent/Child/Grandchild/insert-page-here with Director::redirect()

    Thanks in advance!

    -Luke

  • simon_w
    Avatar
    Forum Moderator
    467 Posts

    Re: How to get full URL in 2.4 Link to this post

    If you've got the page already, $page->Link(), otherwise SiteTree:get_by_link('insert-page-here')->Link(), however that'll only work if 'insert-page-here' is a unique URLSegment.

  • theoldlr
    Avatar
    Community Member
    103 Posts

    Re: How to get full URL in 2.4 Link to this post

    Thanks!

    SiteTree:get_by_link('insert-page-here')->Link() was exactly what I was looking for.

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