Velocity rendering values differently

Hello,

I have the following code in my template


## read the link_title
#set($link_title = $sys.item.getProperty("rx:link_title").String)

##read from slot slotUrl
#set($slotname = "slotUrl")
#set($slotparams = "")##

#initslot($slotname $slotparams)##
 #if($sys.currentslot.relresults.size() > 0)
   #foreach($relresult in $sys.currentslot.relresults )
     #set($url = $relresult.getNode().getProperty("rx:url").String)
  #end
 #end
#endslot($slotname)

## print the value of url read from slot
$url 

##create hyperlink for link_title
--
<a href="$url">$link_title</a>
--

When I preview this page,
I can see that $url is outputted as “www.irs.gov
But the building of hyperlink does not happen properly. Instead of linking to www.irs.gov an hyperlink is created to “http://percussion.aquilent.com:9992/EI_Home/Demo2/www.irs.gov

When I do view source, it is displayed as

www.irs.gov
--
<a href="www.irs.gov">file taxes here1</a>
--

Can some one please tell me why the hyperlink is not building properly?

Regards
Ravi

Hi Ravi

You just need to put “http://” before your “www.irs.gov” else the “www.irs.gov” will just been seen as a local folder.

Cheers
James

Thank you James,
did not even realise it was that simple.

On the same lines, Could you please tell me if it is possible to force a template when adding an item to a slot?

User will add an item to a slot and choose a display template for that item. We have a requirement where we need to ignore the template choice made by the user and force another template logic on the item. Is it possible?

Ravi

You can specify a template parameter when you call the slot macro. The parameter can be either the “name” (NOT the “label”) or the “id” of the desired template.