I should also add that this works like a charm. I just cannot figure out how to do an array. I set this up exactly the same as the first one except the DAMP data type is using a single media item.
but that didn't work either. Now I'm getting this error on the actual page :
Error loading Razor Script Slideshow.cshtml Cannot get MediaById without an id
I'm using an id for the datatype, though. This seems like an error message that I'd only get from using full media xml in the datatype. I tried that just to see what would happen and I get this error :
Error loading Razor Script Slideshow.cshtml Object reference not set to an instance of an object.
I'm going to look more closely at the Cultiv Razor Examples. I just didn't recall seeing a useable example. I just want the classic to work as a multiple. I don't need to recrop the images.
If you only use the id and store multiple images the ids are stored in a csv format. For example the value may look like this: "1056,1089,1103". You first need to split the string, loop trough that and than use Model.MediaById.
For splitting the string you can do something like this:
@{ if (Model.HasValue("HomePageSlideShow")) { dynamic mediaItems = Model.HomePageSlideShow.mediaItem; if (mediaItems.Count() != 0) { <ul> @foreach (var item in mediaItems) { var image = item.Image; <li> <img src="@image.umbracoFile" alt="@image.nodeName" /> </li> } </ul> } } }
Thanks for your input, Jeroen. I don't think I would've figured it out unless I actually looked at the Cultiv Razor Examples. They proved to be more useful than I thought they would be.
Classic Image Array for a slideshow using Razor
I cannot get this to work. It was constructed using the examples file in Umbraco 4.7.1.
This is the error that I'm getting :
c:\HostingSpaces\xxx\xxx.com\wwwroot\macroScripts\634563041717224178_Slideshow.cshtml(6): error CS1515: 'in' expected
I should also add that this works like a charm. I just cannot figure out how to do an array. I set this up exactly the same as the first one except the DAMP data type is using a single media item.
Isn't it just a typo? This is what you have:
And I think it should be this:
But even if you do that you are using Model.MediaById. Doesn't that always return 1 item so can you do a foreach on that?
Here is the Razor code I used in the example. It's a bit different.
Jeroen
You could also have a look at the Cultiv Razor Examples project. It also has some nice DAMP examples.
Jeroen
I changed the code to:
but that didn't work either. Now I'm getting this error on the actual page :
I'm using an id for the datatype, though. This seems like an error message that I'd only get from using full media xml in the datatype. I tried that just to see what would happen and I get this error :
I'm going to look more closely at the Cultiv Razor Examples. I just didn't recall seeing a useable example. I just want the classic to work as a multiple. I don't need to recrop the images.
If you only use the id and store multiple images the ids are stored in a csv format. For example the value may look like this: "1056,1089,1103". You first need to split the string, loop trough that and than use Model.MediaById.
For splitting the string you can do something like this:
Jeroen
I got it to work using the full xml in the datatype. Here is the code I'm using to extract the uncropped images :
Thanks for your input, Jeroen. I don't think I would've figured it out unless I actually looked at the
Cultiv Razor Examples. They proved to be more useful than I thought they would be.
plz help me how to create slide image in umbraco 6.what is the steps?
is working on a reply...