So I started working on this on v7 at home and thought I had an idea of how to do it, but my work uses v6 still, and I'm having trouble translating what I figured out in v7 to v6 and making the actual macro work properly.
I'm trying to create a slideshow that can be populated with images that are on the back end of news articles. So in v7 I could create an input in the introduction section of the template with the alias image, and keep each image there. I'm not sure what the equivalent to this would be in v6.
From there, I'm trying to use the partial view macro template "List Child Pages from Changeable Source" to pull the images for a collection of articles. In v7 I managed to get the macro to populate, but the images were not displaying. In v6 I can't even get the macro in it's base form to function.
From there I want to attempt to create a slider populated with the images associated with the source. Obviously I need to figure out how to just get the images to populate before I move on to that step though.
I've been looking and can't find any record of anyone trying to create something similar, so maybe there is an easier way to go about this, but I would love some help, I am new to Umbraco and Razor and am not really sure what resources to be looking at.
What you can do is to create a Partial View/Macro where you let the user picker a folder from the media library and then loop through the images that you have in this folder.
So If you go to the developer section, and create a partial view macros then you can use some pre-define snippets If you choose the one called gallery, then the user get the option to select an folder from the media library or multiple images.
The partial view looks like this.
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
Macro to display a gallery of images from media the media section.
Works with either a 'Single Media Picker' or a 'Multiple Media Picker' macro parameter (see below).
How it works:
- Confirm the macro parameter has been passed in with a value
- Loop through all the media Id's passed in (might be a single item, might be many)
- Display any individual images, as well as any folders of images
Macro Parameters To Create, for this macro to work:
Alias:mediaIds Name:Select folders and/or images Type: Multiple Media Picker
Type: (note: you can use a Single Media Picker if that's more appropriate to your needs)
*@
@{ var mediaIds = Model.MacroParameters["mediaIds"]; }
@if (mediaIds != null)
{
<ul class="thumbnails">
@foreach (var mediaId in mediaIds.ToString().Split(','))
{
var media = Umbraco.Media(mediaId);
@* a single image *@
if (media.DocumentTypeAlias == "Image")
{
@Render(media);
}
@* a folder with images under it *@
if (media.Children("Image").Any())
{
foreach (var image in media.Children("Image"))
{
@Render(image);
}
}
}
</ul>
}
@helper Render(dynamic item)
{
<li class="span2">
<a href="@item.umbracoFile.src" class="thumbnail">
<img src="@item.umbracoFile.src" alt="@item.Name" />
</a>
</li>
}
The important thing to get this working is to remember to add the macro parameter with the alias of mediaIds and the type should be set to Multiple Media Picker
Need help building a Partial View/Macro
So I started working on this on v7 at home and thought I had an idea of how to do it, but my work uses v6 still, and I'm having trouble translating what I figured out in v7 to v6 and making the actual macro work properly.
I'm trying to create a slideshow that can be populated with images that are on the back end of news articles. So in v7 I could create an input in the introduction section of the template with the alias image, and keep each image there. I'm not sure what the equivalent to this would be in v6.
From there, I'm trying to use the partial view macro template "List Child Pages from Changeable Source" to pull the images for a collection of articles. In v7 I managed to get the macro to populate, but the images were not displaying. In v6 I can't even get the macro in it's base form to function.
From there I want to attempt to create a slider populated with the images associated with the source. Obviously I need to figure out how to just get the images to populate before I move on to that step though.
I've been looking and can't find any record of anyone trying to create something similar, so maybe there is an easier way to go about this, but I would love some help, I am new to Umbraco and Razor and am not really sure what resources to be looking at.
Hi Lydia and welcome to our.
What you can do is to create a Partial View/Macro where you let the user picker a folder from the media library and then loop through the images that you have in this folder.
So If you go to the developer section, and create a partial view macros then you can use some pre-define snippets If you choose the one called gallery, then the user get the option to select an folder from the media library or multiple images.
The partial view looks like this.
The important thing to get this working is to remember to add the macro parameter with the alias of mediaIds and the type should be set to Multiple Media Picker
Hope this make sense and helps,
/Dennis
is working on a reply...