I want to list all child images and link of GalleyCatagorie on the homepage. before with dynamic node i would have used NodebyID. The example below is from dynamic node, I want to know how to do this with MVC.
@{
<div class="FeaturedProduct">
@foreach (var group in @Model.NodeById(2045).Children.InGroupsOf(3))
{
foreach(var item in group)
{
// find you whether is the first item of the group and set the css class
var itemClass = item.IsFirst("first item left", "item left");
// If there is not photo, fallback to the placeholder
var src = @item.Cropper ?? "/images/Placeholders/photo_placeholder.gif";
<div class="image">
@if (Model.HasValue("Cropper"))
{
<img src="@Model.Cropper.Find("@name", "250").url" /><br />
}
</div>
}
// Clear after each group of 3
<div class="clearBoth"> </div>
}
</div>
}
Here is the updated code but i do not get images or links it shows the divs
@{
<div class="FeaturedProduct">
@foreach (var group in Umbraco.TypedContent(1101).Children.InGroupsOf(3))
{
foreach (var item in group)
{
// find you whether is the first item of the group and set the css class
var itemClass = item.IsFirst("first item left", "item left");
// If there is not photo, fallback to the placeholder
var src = @item.GetCropUrl("cropper", "thumbnail");
<div class="image">
@if (Model.Content.HasValue("cropper"))
{
<img src="@item.Url" alt="@item.Name" /><br />
<h3><a href="@item.Url">@item.Name</a></h3>
}
</div>
}
// Clear after each group of 3
<div class="clearBoth"> </div>
}
</div>
List children of a content ID with MVC
I want to list all child images and link of GalleyCatagorie on the homepage. before with dynamic node i would have used NodebyID. The example below is from dynamic node, I want to know how to do this with MVC.
Hi Keith,
I think something like the following should work...
Thanks, Dan.
Here is the updated code but i do not get images or links it shows the divs
@{
}
Hi Keith,
I think your if statement is using the wrong object and your image is using the wrong url. Instead of Model, shouldn't it use item?
Thanks, Dan.
no need for a if statement.
is working on a reply...