2864 Posts in 732 Topics by 700 members
Template Questions
SilverStripe Forums » Template Questions » How to print Variable as part of string larger string
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 793 Views |
-
How to print Variable as part of string larger string

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?
-
Re: How to print Variable as part of string larger string

20 January 2010 at 6:27pm
You can 'escape' the variable by using { }. Eg SomeStringWith{$AVar}InTheMiddle
-
Re: How to print Variable as part of string larger string

26 January 2010 at 11:43am
thank you. exactly what i needed.
| 793 Views | ||
|
Page:
1
|
Go to Top |


