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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

How to get full URL in 2.4


Go to End


3 Posts   3302 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
(deleted)

Community Member, 473 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.