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

Template Questions /

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

External link from the template

Go to End

6 Posts   2892 Views


Community Member, 19 Posts

23 February 2012 at 3:43am

Hi all!!

I know it should be simple, but since I am into silverstripe some months ago I have sometimes problem with smallest things.

I am trying to generate in my template one picture with a link to external site. This link will be written by my customer when he makes and entry in the cms, so will come from DB. The problem is, the link is coming right, but the finall result is link with the baseurl in the href that look like this "http://mydomain/parentpage/".

The code in the template is:

<div class="typography">
<% control Items %>
<p><a target="_blank" href="http//www.$ExternalLink/" rel="external">$Photo.SetWidth(50)</a></p>
<a href="$Link">View</a>
<% end_control %>

$ExternalLink is a text type in DB

Thanks Greetings


Community Member, 19 Posts

28 February 2012 at 9:36am

one way is:

class Item extends DataObject { 

public function getItemURL() {
return 'http://blablabla/'.$this->ExternalLink; 


in template use 



Community Member, 19 Posts

20 April 2012 at 12:20am

Hi mishell,

sorry I had left this project for a moment to focus on anothers. I forgot totally about my post.

I am trying your solution, but it doesn´t work, the issue I think is different, how SS handle the template and treats the <a href> tags. Because the $ExternalLink is showing right if I place it in h2 for example.

I mean if I even use static word for example:

<a href="Hellloworld" rel="external">linkName</a>

SS is adding the baseUrl before Helloworld when build the template, so the final:

href --> 'http//'

What I want to get is href --> 'Helloworld' only to then I build my link on my own.

Thanks for your reply, bye


Community Member, 19 Posts

20 April 2012 at 12:53am

Hehehe, it is done! Problem solved

Thnx again!!


Community Member, 82 Posts

22 July 2012 at 3:27am

Can you share the solution you found. thanx


Community Member, 22 Posts

30 July 2017 at 9:49am

@Bolixe yes this would be very useful thank you.