Any particular reason why you want to make this directly in the masterpage?
I suggest looking into making a XSLT macro to render your image instead. Or maybe even Razor - however I don't have any Razor skills yet so I can't say how to do it.
But I'd like to hear if there is a specific reason as to why you wish to make the check in the masterpage - 'cause you'll still ned to lookup the image etc.
Jan, on this project we have a few developers. Some C# guys or more front-end peeps like me, so I don't know C# well enough to do what they do but I can (just about) get my head around XLST.
Probably not the best way of doing things but Umbraco is a new setup for us so I imagine over time we will create re-usable code snippets in one or the other.
if statement in masterpage
Hi, hope this is in the right place.
I need to create something like this:
<li><a href="#"><img src="photo.jpg" /></a></li>
The photo is a document/property type. But it might not exist. If it doesn't exist I don't want to render the <li>
Is there a simple if statement to check for a null value or something like that?
Thanks
Hi Tom
Any particular reason why you want to make this directly in the masterpage?
I suggest looking into making a XSLT macro to render your image instead. Or maybe even Razor - however I don't have any Razor skills yet so I can't say how to do it.
But I'd like to hear if there is a specific reason as to why you wish to make the check in the masterpage - 'cause you'll still ned to lookup the image etc.
/Jan
Hi.
Only reason is because I have various other things in the masterpage and they all work fine without the need to do any XLST (which I struggle with).
Happy to use a XLST if necessary.
Hi Tom,
Here's logic I used for a checkbox, you could adapt for a media picker and check to see ift he property value is NullOrEmpty:
See this similar thread that has a similar solution, perhaps a bit more flexible and error-proof: http://our.umbraco.org/forum/templating/templates-and-document-types/15707-if-statement-on-masterpage?p=0#comment57895
I would still probably favor a macro though :)
Thanks,
Tom
Ended up doing this in XLST:
Hi Tom
Happy to hear you found the solution - why did you end up using XSLT instead of C#? (just curious)
/Jan
Jan, on this project we have a few developers. Some C# guys or more front-end peeps like me, so I don't know C# well enough to do what they do but I can (just about) get my head around XLST.
Probably not the best way of doing things but Umbraco is a new setup for us so I imagine over time we will create re-usable code snippets in one or the other.
Tom Fulton,
Thanks so much for posting the checkbox markup. I'm new to Umbraco and you saved me from so much headache. I signed up just to say thanks :)
cheers,
Guru
is working on a reply...