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 /

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

How to print Variable as part of string larger string

Go to End

3 Posts   1498 Views


Community Member, 45 Posts

20 January 2010 at 2:38am

I need to add a mouseover event to navigation links and want to have the $URLSegment as part of the unique name. However, it appears that I cannot do this b/c the variable is inserted in the middle of a larger string.

see example below:

<a href="$Link" onMouseOver='document.nav_$URLSegment.src=nav_$URLSegment_over.src;' onMouseOut='document.nav_$URLSegment.src=nav_$URLSegment_off.src;'><img src="/$ThemeDir/images/nav-$URLSegment-off.jpg" name="nav_$URLSegment" style="display:block;border:none;padding-left:5px;float:right;" /></a>

other than creating functions to handle creating the entire string, is there another method to be able to tell the template where to start or end the variable name?


Forum Moderator, 5523 Posts

20 January 2010 at 6:27pm

You can 'escape' the variable by using { }. Eg SomeStringWith{$AVar}InTheMiddle


Community Member, 45 Posts

26 January 2010 at 11:43am

thank you. exactly what i needed.