How do i get the First Value in a Media Folder using GetChildMedia()
Media StartMedia = new Media(@Id); foreach(Media p in StartMedia.GetChildMedia()){ @p.getProperty("umbracoFile").Value <br/>if(p.IsFirst()){}@StartMedia.Children.First().getProperty("umbracoFile").Value }
Here am getting an error when saving the file
error CS1061: 'umbraco.cms.businesslogic.media.Media' does not contain a definition for 'IsFirst
No worries - that seems more efficient than my method, which adds an extra variable and increments it in the loop to grab just one item - will note your method for future!
FWIW at the moment the IsFirst(), IsLast() etc methods and properties are somewhat buggy in 6.1 and previous versions. Current working on fixing them, hopefully sometime after CG13 we'll have clean methods.
IsFirst or IsPosition in Media
Hi Guys,
How do i get the First Value in a Media Folder using GetChildMedia()
Here am getting an error when saving the file
Any thoughts on this ?
before the for each :
then in the foreach
Hi Joe,
Thanks for the response.
I somehow did it in another way. I checked if the first media in the loop matches the id
No worries - that seems more efficient than my method, which adds an extra variable and increments it in the loop to grab just one item - will note your method for future!
Joe
FWIW at the moment the IsFirst(), IsLast() etc methods and properties are somewhat buggy in 6.1 and previous versions. Current working on fixing them, hopefully sometime after CG13 we'll have clean methods.
Hi Stephen,
Thanks for pointing this out .
is working on a reply...