I don't know what version of Umbraco you're using but I thing in v6 and above you should be able to do something like (code abbreviated):
@using Umbraco.Web
@{
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var myNode = umbracoHelper.TypedContent(1234);
}
@foreach (var item in myNode.Children.Where(x => x.IsVisible()))
{
if (item.HasValue("image"))
{
if (!item.GetPropertyValue<bool>("isVideo") || !item.GetPropertyValue<bool>("isSlideshow"))
{
// and so on
// you can get properties of type string like so:
// item.GetPropertyValue<string>("myPropertyAlias")
// or int:
// item.GetPropertyValue<int>("myPropertyAlias")
// etc.
}
}
}
It is a little more verbose but you also get a lot more intellisense and code completion if you're working in Visual Studio. This also gets you out of the realm of dynamics which don't perform nearly as well.
Again, if this works depends on your VS version but it might benefit you.
If Statement to Check for "True / False"
I've been banging my head on this. I can't seem to get a check for a doctype property of true/false to work. What is wrong with my syntax?
are you sure the property type is boolean?
try
if ( !bool.Parse(item.isVideo) || !bool.Parse(item.isSlideshow)
Yes, I just now got it to work, but the fact that I had to do it exactly this way is crazy. Here is the only way I could it it to test properly.
I don't know what version of Umbraco you're using but I thing in v6 and above you should be able to do something like (code abbreviated):
It is a little more verbose but you also get a lot more intellisense and code completion if you're working in Visual Studio. This also gets you out of the realm of dynamics which don't perform nearly as well.
Again, if this works depends on your VS version but it might benefit you.
Thanks Sebastiaan. I don't think I've seen this way of using the "type" of the returned value of the property. But it's good to know going forward.
is working on a reply...