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.

Template Questions

External link from the template


5 Posts   806 Views


23 February 2012 at 3:43am Community Member, 17 Posts

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


28 February 2012 at 9:36am Community Member, 19 Posts

one way is:

class Item extends DataObject {

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


in template use



20 April 2012 at 12:20am Community Member, 17 Posts

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


20 April 2012 at 12:53am Community Member, 17 Posts

Hehehe, it is done! Problem solved

Thnx again!!


22 July 2012 at 3:27am Community Member, 82 Posts

Can you share the solution you found. thanx