I have a folder called "gallery" you can create a galleryCategory which is the title of the gallery. In the gallery category you can add multiple galleryItems(these are just pics_. I need a loop inside a loop in Razor to output my html which is
@foreach (var gallery in Model.NodeById(1599).Children) { <h2>gallery.Title</h2> @foreach (var galleryitem in NodeById(gallery.id).Children) { //output the pics here } } </umbraco:Macro>
What are the properties on your "galleryitem" node? (This is a document type, and not a media type, correct?)
As an example, if you are using the "upload" datatype directly on a document type called "pic", here is one way to do it...
@foreach (var galleryitem in NodeById(gallery.id).Children) { //output the pics here <img src="@galleryitem.pic" alt="" /> }
If you were using a "media picker" datatype called imageId, here is another way to do that... (since a media picker just stores an ID for reference, not the name of the file like the previous example.)
@foreach (var galleryitem in NodeById(gallery.id).Children) { //output the pics here var m = Library.MediaById(galleryitem.imageId); <img src="@m.umbracoFile" alt="" /> }
You did not mention what kind of properties were on your "galleryitem" content type. Without knowing this, it is hard to guess exactly what the problem might be. (Different data types have different ways of storing the underlying data.)
Output my gallery in razor
I have a folder called "gallery" you can create a galleryCategory which is the title of the gallery. In the gallery category you can add multiple galleryItems(these are just pics_. I need a loop inside a loop in Razor to output my html which is
<div class="gallery-category">
<h3>edinburgh’s great icon</h3>
</div>
<div class="slides">
<div class="gallery-slider" style="width: 1740px; margin-left: 0px;">
<img width="120" height="120" data-fullsize="img/galleryimages/fullsize/1.jpg" alt="1" src="img/galleryimages/1.jpg" class="gallery-image">
</div>
my razor
<asp:content ContentPlaceHolderId="mainContent" runat="server">
<umbraco:Macro runat="server" language="cshtml">
@foreach (var gallery in Model.NodeById(1599).Children) {
<h2>gallery.Title</h2>
@foreach (var galleryitem in NodeById(gallery.id).Children) {
//output the pics here
}
}
</umbraco:Macro>
What are the properties on your "galleryitem" node? (This is a document type, and not a media type, correct?)
As an example, if you are using the "upload" datatype directly on a document type called "pic", here is one way to do it...
If you were using a "media picker" datatype called imageId, here is another way to do that... (since a media picker just stores an ID for reference, not the name of the file like the previous example.)
Best of luck to you!
got it, what you posted was close,
This was giving me an error
@foreach (var gallery in Model.NodeById(1599).Children) {
<h2>@gallery.Id</h2>
foreach (var galleryitem in gallery.Children) {
}
}
Hello again Rocoeh,
You did not mention what kind of properties were on your "galleryitem" content type. Without knowing this, it is hard to guess exactly what the problem might be. (Different data types have different ways of storing the underlying data.)
Good luck!
is working on a reply...