tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/12086-test-for-the-existence-of-a-file-inside-of-cascadeCascade CMS: Discussion 2015-08-12T16:36:11Ztag:help-archives.hannonhill.com,2010-02-09:Comment/372507412015-08-07T20:14:40Z2015-08-07T20:14:40ZTest for the existence of a file inside of Cascade<div><p>Hm, definitely interesting.</p>
<p>One thing I was curious about, but not sure it will make a
difference, is to try removing the following line:</p>
<pre>
<code>#set ($imageCheck = "" )</code>
</pre>
<p>I'm wondering if there's something weird going on when when the
variable goes from a String to a File object.</p>
<p>Let me know if this changes anything.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/372507412015-08-07T20:16:53Z2015-08-07T20:16:53ZTest for the existence of a file inside of Cascade<div><p>Ryan,<br>
I removed that line and it didn’t make a difference. With the
format as attached, it is still outputting code for an image file
for every provider.<br>
Thanks,<br>
Lauren</p></div>lauren.frasertag:help-archives.hannonhill.com,2010-02-09:Comment/372507412015-08-07T20:22:52Z2015-08-07T20:22:52ZTest for the existence of a file inside of Cascade<div><p>Thank you for trying, Lauren.</p>
<p>Also curious, but try adding another line of debug:</p>
<pre>
<code>$imageName
$imageCheck
$_PropertyTool.isNull($imageCheck)</code>
</pre>
<p>I'm wondering if maybe something weird is going on with the
image name field.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/372507412015-08-07T20:31:40Z2015-08-07T20:31:40ZTest for the existence of a file inside of Cascade<div><p>Here is the result from adding <code>$imageName</code><br></p>
<pre>
<code>david-sommerfeld
com.hannonhill.cascade.api.adapters.FileAPIAdapter@655e6f8d
false<br><br>
<br><div class="top-Find-Doctor-container cf">
<div class="Find-Doctor-left">
<h2>
<a href="site://1.citizensmemorial.com/providers/david-sommerfeld"> David Sommerfeld, MD</a>
</h2>
<span>Nephrology</span>
<p>
Parkview Orthopaedic Clinic
</p>
</div>
<div class="Find-Doctor-right">
<div class="provider-image">
<img src="[system-asset]_common/images/providers/david-sommerfeld.png[/system-asset]" />
</div>
</div>
</div>
<div class="divider-mobile" /><br><br>
<br>deanna-holeman<br><br>
<br>false<br><br>
<br><div class="top-Find-Doctor-container cf">
<div class="Find-Doctor-left">
<h2>
<a href="site://1.citizensmemorial.com/providers/deanna-holeman"> DeAnna Holeman, LCSW</a>
</h2>
<p>
Dallas County Family Medical Center
</p>
</div>
<div class="Find-Doctor-right">
<div class="provider-image">
<img src="[system-asset]_common/images/providers/deanna-holeman.png[/system-asset]" />
</div>
</div>
</div>
<div class="divider-mobile" /></code>
</pre>
<p>I should not that I put back in <code>#set ($imageCheck = ""
)</code>.<br>
Without it, all of the outputs for <code>$imageCheck</code> were
showing the same.</p></div>lauren.frasertag:help-archives.hannonhill.com,2010-02-09:Comment/372507412015-08-12T15:54:47Z2015-08-12T15:54:47ZTest for the existence of a file inside of Cascade<div><p>Weird, but glad that helps resolve that issue. If you don't
mind, I'd like to use the login info you've provided in a previous
discussion to take a closer look at this. I will be in touch as
soon as I have additional information.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/372507412015-08-12T16:10:06Z2015-08-12T16:10:06ZTest for the existence of a file inside of Cascade<div><p>Ryan,<br>
That would be great. Let me know if you have any questions once you
get in there.<br>
Thanks,<br>
Lauren</p></div>lauren.frasertag:help-archives.hannonhill.com,2010-02-09:Comment/372507412015-08-12T16:12:41Z2015-08-12T16:12:41ZTest for the existence of a file inside of Cascade<div><p>Hi Lauren,</p>
<p>I was able to track down the problem. So when the Locator Tool
is not able to actually return a Cascade API object (a File in this
case), it will just dump the literal code to the
<code>$imageCheck</code> variable. This explains why the Property
Tool wasn't working.</p>
<p>To work around this, we should be checking for the existence of
a property and falling back to the generic images if the property
was not found. I already made this change to your Format, but for
reference here is what I modified:</p>
<pre>
<code>#if ( !$_PropertyTool.isNull($imageCheck.name) )
<img src="[system-asset]${imageCheck.link}[/system-asset]" />
#else
#if ($gender.value != "F")
<img src="[system-asset:id=1d1d66f0ac1009d000cf095e4a81bbe2]/_common/images/providers/man.png[/system-asset]" />
#else
<img src="[system-asset:id=1d153e88ac1009d000cf095eb7af1ae6]/_common/images/providers/woman.png[/system-asset]" />
#end
#end</code>
</pre>
<p>Note: I also adjusted the way you are outputting the provider's
image. You already did the work to load the file, so you might as
well use that file object's <code>link</code> value instead of
building out the path manually. Won't make a huge difference, but
why manually build that path twice.</p>
<p>Also, I noticed that <strong>Barbara "Toni" Hudson</strong> does
in-fact have an image, but it's named differently than the provider
page. A drawback to the way this is implemented, but at least an
easy fix.</p>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/372507412015-08-12T16:27:17Z2015-08-12T16:27:17ZTest for the existence of a file inside of Cascade<div><p>Ryan,<br>
Thanks for the quick fix.<br>
Lauren</p></div>lauren.frasertag:help-archives.hannonhill.com,2010-02-09:Comment/372507412015-08-12T16:36:11Z2015-08-12T16:36:11ZTest for the existence of a file inside of Cascade<div><p>Not a problem at all, Lauren, I am glad to hear the change did
the trick.</p>
<p>I'm going to go ahead and close this discussion, please feel
free to comment or reply to re-open if you have any additional
questions.</p>
<p>Have a great day!</p></div>Ryan Griffith