Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Umbraco Version: 7.10.1 Archetype Version: 1.18.0
public ActionResult RenderGallerySection() { List<GalleryItem> model = new List<GalleryItem>(); IPublishedContent homePage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault(); ArchetypeModel GalleryItems = homePage.GetPropertyValue<ArchetypeModel>("galleryItems"); foreach (ArchetypeFieldsetModel fieldset in GalleryItems) { string imageCategory1 = fieldset.GetValue("name").ToString(); //Get the URL of the Image var imageIdsmall = fieldset.GetValue<IPublishedContent>("shortImage"); var mediaItemSmall = Umbraco.Media(imageIdsmall); string smallImgUrl = mediaItemSmall.Url;
This line of code returns null: var imageIdsmall = fieldset.GetValue
However when I add a watch to "fieldset" i can see the image URL
Please help
Hi Praveen
Use "Umbraco.AssignedContentItem" instead of CurrentPage. CurrentPage is dynamic type, which is not good and hard to debug
IPublishedContent homePage = Umbraco.AssignedContentItem.AncestorOrSelf(1).DescendantsOrSelf().FirstOrDefault(x => x.DocumentTypeAlias == "home"); ArchetypeModel GalleryItems = homePage.GetPropertyValue<ArchetypeModel>("galleryItems"); foreach (ArchetypeFieldsetModel fieldset in GalleryItems) { string imageCategory1 = fieldset.GetValue("name").ToString(); //Get the URL of the Image var imageIdsmall = fieldset.GetValue<IPublishedContent>("shortImage"); }
Thanks,
Alex
Hi Alex
Many thanks for the quick reply
now the variable imageIdsmall has value
var imageIdsmall = fieldset.GetValue
However the next two lines have null value: var mediaItemSmall = Umbraco.Media(imageIdsmall); string smallImgUrl = mediaItemSmall.Url;
Praveen, what is output of imageIdsmall?
Hi Alex, Really appreciate your help
below two lines resolved the issue, now I am able to get the Url //Get the URL of the Image string imageUrlSmall = fieldset.GetValue
Can you please advise how to loop through the items to render the html:
@inherits UmbracoViewPage<>
foreach(@Model in GalleryItem) { @RenderGalleryItem(@Model[0]) }
Please, clarify what to render, and show all code
I want to render the below in foreach loop @RenderGalleryItem(@Model[0])
Praveen, why do you pass List as a model? Just get list in the view
Sorry Alex, I don't understand, can you please elobrate Many thanks
Thanks Alex, resolved
You are welcome, Praveen, have a nice day!
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Archetype - unable to get the fieldset property values
Umbraco Version: 7.10.1 Archetype Version: 1.18.0
This line of code returns null: var imageIdsmall = fieldset.GetValue
However when I add a watch to "fieldset" i can see the image URL
Please help
Hi Praveen
Use "Umbraco.AssignedContentItem" instead of CurrentPage. CurrentPage is dynamic type, which is not good and hard to debug
Thanks,
Alex
Hi Alex
Many thanks for the quick reply
now the variable imageIdsmall has value
var imageIdsmall = fieldset.GetValue
However the next two lines have null value: var mediaItemSmall = Umbraco.Media(imageIdsmall); string smallImgUrl = mediaItemSmall.Url;
Praveen, what is output of imageIdsmall?
Hi Alex, Really appreciate your help
below two lines resolved the issue, now I am able to get the Url //Get the URL of the Image string imageUrlSmall = fieldset.GetValue
Can you please advise how to loop through the items to render the html:
@inherits UmbracoViewPage<>
Please, clarify what to render, and show all code
I want to render the below in foreach loop @RenderGalleryItem(@Model[0])
Praveen, why do you pass List as a model? Just get list in the view
Sorry Alex, I don't understand, can you please elobrate Many thanks
Thanks Alex, resolved
You are welcome, Praveen, have a nice day!
is working on a reply...