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

Director::BaseURL() in Template?


Reply


3 Posts   7992 Views

Avatar
Mo

Community Member, 514 Posts

27 October 2009 at 2:29am

Hey all,

Anyone know id there is a template tag to retrieve Director::BaseURL() from a template? I can create a method like:

public function getBaseUrl() {
return Director::BaseURL();
}

But I was wondering if maybe there is something I can already use and not create duplicate code?

Cheers,

Mo

Avatar
Mo

Community Member, 514 Posts

27 October 2009 at 3:25am

Never mind, I found it: $BaseHref

:)

Avatar
house98

Community Member, 31 Posts

13 January 2010 at 9:20am

Edited: 13/01/2010 6:40pm

Just an addition... if you're wanting to get the page's full URL inside a template for something like a Digg link.. you can do the following

{$BaseHref}{$Top.URLSegment}

Hope this helps others.

[[Edited by Admin]]