I have this problem for a long time now but I really need to address it.
I've configured a DAMP datatype to allow for the picking of zero or more items. I've got some Razor script that wants to display just the first item which is great if one has been picked but it errors if one has not.
No matter what checks I try to put in place I cannot get to check for no items without error.
How to detect if no items have been picked?
I have this problem for a long time now but I really need to address it.
I've configured a DAMP datatype to allow for the picking of zero or more items.
I've got some Razor script that wants to display just the first item which is great if one has been picked but it errors if one has not.
No matter what checks I try to put in place I cannot get to check for no items without error.
The basic script:
Can someone help me fix this?
Regards,
Matt
If you try the DAMP Razor Model (use the old Razor version for this code) it has an .Any property which is false if no items are selected.
Jeroen
Thanks Jeroen,
I'm using Umbraco v6, should I not be using the 2nd version, DAMP Property Editor Value Converter?
Regards,
Matt
It's a long story, but there are 2 versions of Razor in Umbraco. You can see it by the inherit code in your Razor file:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage = new MVC Razor
@inherits umbraco.MacroEngines.DynamicNodeContext = old Macro Razor
For both I wrote a converter. More info:
https://groups.google.com/d/msg/umbraco-dev/WC_7OTF_lO0/31b_k4vsJ90J
http://our.umbraco.org/projects/backoffice-extensions/digibiz-advanced-media-picker/digibiz-advanced-media-picker/38888-Nothing-Seems-to-Work#comment141954
Jeroen
Ah OK, yes I'm not using the MVC rendering engine. I understand.
Thanks,
Matt
Works nicely, thanks.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.