But if you are looping through the children won't this just always work? If there is only one child node it will only loop once and simply only show one image.
@Jeroen Breuer: Yes, he only shows one image, but that one needs to be bigger (full size in gallery) and has a link bellow it. (now it opens colorbox).
Razor count items
How can i do this in razor:
How can i make this if (i think) structure in razor (c# / umbraco)?
Hello,
Are @Model.fotoGallerij in you foreach loop children of your current node? Because there is a count method you can use: http://umbraco.com/follow-us/blog-archive/2011/2/23/umbraco-47-razor-feature-walkthrough-%E2%80%93-part-1.aspx.
But if you are looping through the children won't this just always work? If there is only one child node it will only loop once and simply only show one image.
Jeroen
@Jeroen Breuer: Yes, he only shows one image, but that one needs to be bigger (full size in gallery) and has a link bellow it. (now it opens colorbox).
Hmm perhaps somethings like this?
Jeroen
@Jeroen Breuer: Thanks, that looks like a good solution to me. but:
i'll get: 'umbraco.item' does not contain a definition for 'Image'
Could you post the entire stack trace when you get the error? You can do this by adding ?umbDebugShowTrace=true to the querystring.
Jeroen
How to do that? i've googled on that but i don't get more error information
If it's not working that means it's probably disabled. Try setting this in the web.config:
Jeroen
Allright,
i've tried the following code:
@inherits umbraco.MacroEngines.DynamicNodeContext
@if (Model.fotoGallerij.Count() == 1)
{
@* <img src ="/ImageGen.ashx?height=500&constrain=true&crop=resize&[email protected]" alt=""> *@
}
else if (Model.fotoGallerij.Count() > 1)
{
<ul class="image-gallery">
@foreach (var item in @Model.fotoGallerij)
{
<li>
<a class="gallery grouped" href="/ImageGen.ashx?height=500&constrain=true&crop=resize&[email protected]" title="">
<img src="/ImageGen.ashx?width=71&height=73&crop=resize&[email protected]" alt=""/></a>
</li>
}
</ul>
<script>
$("a.gallery").colorbox({rel:'grouped'});
</script>
}
This runs good, but when i uses images in the first if, it give's an error back. (reason of the comment @* and *@)
That's because you are using @item.image (copied from the loop), but because you are not in the foreach loop that won't work.
Have you tried:
Jeroen
is working on a reply...