MM5 Tips & Tricks / mvt:assign and mvt:eval
Finally.
We can now easily assign and display variables in Miva Merchant pages. And, every other built in Mivascript function. Some of those functions that might be useful include:
One of the first things you might use this for is to number lists such as search results. At the top of the foreach loop you would put:
<mvt:assign name="l.counter" value="l.counter + 1" />
Display the counter variable above by using the mvt:eval tag.
<mvt:eval expr="l.counter" />
Most of you who need to assign varaibles probably already use a toolkit module to do so. Just know that there's a better way.
One if the nice things about mvt:eval is that you can display system variables such as current year for a hands-off copyright approach.
copyright <mvt:eval expr="s.dyn_tm_year" /> by Scot's Miva ScriptsRandom Images
Use mvt:eval to display a random image each time a page loads. Put a bunch of images that are named in numerical order (1.jpg, 2.jpg, 3.jpg, etc..) and then use this code to display a random image.
<mvt:assign name="l.random" value="random(10)" /> <img src="slides/&mvt:local:random.jpg">