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.

Archive /

Our old forums are still available as a read-only archive.

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

Absolute URLS


Go to End


10 Posts   10764 Views

Avatar
Fuzz10

Community Member, 791 Posts

10 October 2007 at 12:21am

Hi,

It would be nice to add an absolute/relative URL switch to the CMS (the menu for example now generates relative URL's which , according to some SEO companies , is bad for google).

Avatar
Ingo

Forum Moderator, 801 Posts

10 October 2007 at 5:51am

i thing having "one switch" would be way to global - we deal with this on a case-by-case basis. you can easily transform back and forth between relative and absolute using the Director-class.
if by "the menu" you mean the <% control Menu(1) %> in your template - no problem, just use $BaseUrl $Link.
for the data-types "Text" and "HTMLText", theres a function AbsoluteLinks().
usage in your template for example: $Content.AbsoluteLinks

Avatar
Fuzz10

Community Member, 791 Posts

10 October 2007 at 7:18am

Agreed. ;-)

Thanks for clearing that up !

Avatar
Fuzz10

Community Member, 791 Posts

11 October 2007 at 12:44am

Hi Ingo,

$BaseUrl is empty here ?

Avatar
Fuzz10

Community Member, 791 Posts

19 October 2007 at 9:52pm

Hi Ingo,

I can't figure this out. The BaseUrl variable returns empty here?

Avatar
Ingo

Forum Moderator, 801 Posts

19 October 2007 at 11:32pm

sorry, it should read $BaseHref

Avatar
Fuzz10

Community Member, 791 Posts

20 October 2007 at 1:25am

Edited: 20/10/2007 1:36am

Thanks for your quick reply.

Forgive me for asking silly questions , but how do I concatenate these two strings in the template ($BaseHref and $Link) in such a way it produces a valid URL. I end up with one slash too much. ;-)

Avatar
Ingo

Forum Moderator, 801 Posts

20 October 2007 at 2:49am

lol sorry to put you on a wild-goose-chase here, i didn't really see the obvious:
there's a property $AbsoluteLink in sapphire/core/model/SiteTree.php (the parent-class of every Page-object).

Go to Top