@{
//gets the home page using doc type alias (root node)
var siteRoot = Model.Content.AncestorOrSelf("homePage");
//gets the products page using doc type alias
var galleryPage = siteRoot.Descendant("galleryPage");
//get the latest photos using the album media folder id
var latestPhotos = galleryPage.HasValue("album") ? Umbraco.TypedMedia(galleryPage.GetPropertyValue<int>("album")) : null;
}
@if (latestPhotos != null)
{
foreach (var photo in latestPhotos.Children.OrderBy("createDate desc"))
{
<div class="item @(photo.IsPosition(1, "col-xs-6", "col-md-2 col-sm-3 col-xs-4"))">
<a href="@photo.Url" data-gallery><img class="img-responsive" src="@photo.GetCropUrl(320,320)" alt="" /></a>
</div>
}
}
I am trying to use the isHelpers to test whether 'photo' is in the first two positions in my 'latestPhotos' list. Is that possible? My code above can successfully check if the photo is in position 1 then apply x class and if not apply y class.
Is there a way to check against more than one position? I been reading this on the wiki
Thansk for the response - I will take a look at whether this works. I was just looking for a better way of achieving the following and was wondering if the isHelpers could help
isHelpers 'Help'
Hi All,
I have the following code
I am trying to use the isHelpers to test whether 'photo' is in the first two positions in my 'latestPhotos' list. Is that possible? My code above can successfully check if the photo is in position 1 then apply x class and if not apply y class.
Is there a way to check against more than one position? I been reading this on the wiki
https://our.umbraco.org/documentation/reference/querying/ipublishedcontent/ishelpers
Thanks
Paul
Hi Paul,
What about if you nested the checks. It's not something I've done before but this might do the job.
Nik
Hi Nik,
Thansk for the response - I will take a look at whether this works. I was just looking for a better way of achieving the following and was wondering if the isHelpers could help
@if (latestPhotos != null) { var indexCount = 0;
Many thanks
Paul
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.