I need to do something equivalent to a null check in a template, for example only write an image to a page if there IS an image associated with it. How is this done in Umbraco? My code is below:
Insert the <img src=" and style="whatever:bleh" /> before and after the field when inserting the field in the template - heres an example from my own project
Null Check on <umbraco:Item> tag?
Hi,
I need to do something equivalent to a null check in a template, for example only write an image to a page if there IS an image associated with it. How is this done in Umbraco? My code is below:
Thanks,
Garrett
You can either
<xsl:if test="string($currentPage/data [@alias='articlePhoto') != ''"> </xsl:if> around the call to the image
Using both ways, the image tag will only be written if the field isnt empty
Dan ;-)
Should note that the "insertTextBefore" etc needs to be escaped, but if you do it via the "insert page field" dialogue box this is done automatically.
is working on a reply...