3212 Posts in 847 Topics by 809 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 458 Views |
-
External link from the template

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/http://www.google.es".
The code in the template is:
<div class="typography">
<ul>
<% control Items %>
<h2>$Title</h2>
<p><a target="_blank" href="http//www.$ExternalLink/" rel="external">$Photo.SetWidth(50)</a></p>
<li>
<p>$Content.FirstParagraph</p>
<a href="$Link">View</a>
</li>
<% end_control %>
</ul>
</div>$ExternalLink is a text type in DB
Thanks Greetings
-
Re: External link from the template

28 February 2012 at 9:36am
one way is:
class Item extends DataObject {
public function getItemURL() {
return 'http://blablabla/'.$this->ExternalLink;
}}
in template use
$ItemURL
-
Re: External link from the template

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//www.baseurl.com/dataObject/Helloworld'
What I want to get is href --> 'Helloworld' only to then I build my link on my own.
Thanks for your reply, bye
-
Re: External link from the template

20 April 2012 at 12:53am
Hehehe, it is done! Problem solved
Thnx again!!
-
Re: External link from the template

22 July 2012 at 3:27am
Can you share the solution you found. thanx
| 458 Views | ||
|
Page:
1
|
Go to Top |



