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

How to get full URL in 2.4


Reply


3 Posts   2243 Views

Avatar
theoldlr

Community Member, 103 Posts

21 September 2010 at 8:02am

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

Avatar
simon_w

Forum Moderator, 474 Posts

21 September 2010 at 8:47am

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.

Avatar
theoldlr

Community Member, 103 Posts

21 September 2010 at 9:34am

Thanks!

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