tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/14631-trying-to-get-a-format-to-workCascade CMS: Discussion 2016-10-02T02:45:10Ztag:help-archives.hannonhill.com,2010-02-09:Comment/405528812016-08-16T20:44:59Z2016-08-16T20:44:59ZTrying to get a format to work<div><p>I am trying to turn on and off this image that shows up on my
homepage slideshow. So I created a if statement when the user hits
yes ($umsldailyYesN) you can add and image to it</p>
<div><img class="umsl-daily-icon" src="${slide.getChild('umsldailyicon').getChild('path').value}"></div>
but for some reason I cant get it to work right. It assumes it is
turned on all the time. Could you take a look at it and see what
you think?
<p>Thanks!</p></div>Fernandotag:help-archives.hannonhill.com,2010-02-09:Comment/405528812016-08-19T13:45:59Z2016-08-19T13:45:59ZTrying to get a format to work<div><p>Hi Fernando,</p>
<p>I noticed in your format that you're attempting to check this
here:</p>
<pre>
<code>#set($umsldailyYesNo = $_XPathTool.selectSingleNode($contentRoot, "//system-data-structure/slide/umsldaily1").value)
#if($umsldailyYesNo == "Yes")
...
#else
...
#end</code>
</pre>
<p>I think what might be happening is that you're effectively
checking the same <code>selectSingleNode</code> in every iteration
of your loop. You need to scope your XPath there to either use your
current slide as the context or to specifically access that
<code>umsldaily1</code> node by name as you're doing above for this
other field:<br></p>
<pre>
<code>#set($link = $_EscapeTool.xml($slide.getChild("symlink").getChild("content").getChild("system-symlink").value))</code>
</pre>
<p>Currently, you're checking the same value for the first slide
over and over again.</p>
<p>Let me know if that makes sense.</p>
<p>Thanks!</p></div>Bradley Wagner