I'm trying to use DAMP with umbraco v6 and I'm struggling to find any examples of how DAMP works with the new API? Are there any examples floating about?
At the moment I'm really struggling with working out how to get the first image in a collection using razor...
The V6 API is about creating content and media. When you mean new API, I think you are talking about MVC Razor views? Those are news since 4.10 and not v6 ;-).
Have a look at the DAMP Gallery. That shows how you can use DAMP in Razor.
Thanks Jeroen, that page is exactly what I'm looking at right now :-)
I'm having difficulty retrieving the values though - I've had to configure the data type so it stores the Ids (it's the only way I can get it to work with my installation) yet I can't seem to get any data out.
Using your example, I've tried this:
@{ dynamic i = CurrentPage.backgroundImages; }
<img src="@i[0].umbracoFile" alt=""/>
..but clearly this isn't working. Am I on the right track? The gallery example doesn't seem to show how to get an image at an index?
Why do you want to get an image by index? Currently you're only getting a csv if you do "dynamic i = CurrentPage.backgroundImages" so "i[0].umbracoFile" also won't work. It's different from dynamic xml in the old Razor macro's.
^ we too are using our own extension methods to work with DAMP crops in a standardised manner. It would be great to see DAMP itself have these sorts of helper methods.
ok cool, thanks for the info. Thats a separate package from DAMP though, correct? and it also means using 'dynamic' and our preference is for strongly-typed extensions which is why we've rolled our own.
Hi, thought I'd add a little tip - define DAMP as an alias at the top of the file so that the generic type parameter is shorter, and there's no confusion about which Model is Model:
@using DAMP = DAMP.PropertyEditorValueConverter.Model;
var images = Model.Content.GetPropertyValue<DAMP>("images");
That's because @CurrentPage.section1Image is of the type DAMP.PropertyEditorValueConverter.Model. If you want to show the url of the first selected image you can try this:
You downloaded the correct version, but in your example you use the dynamic features of Umbraco (@CurrentPage) and it's better to use the strongly typed version (@Model.Content). You can read more about it here: http://our.umbraco.org/documentation/Reference/Mvc/querying
"Some complex queries cannot be written dynamically because the dynamic query parser may not understand precisely what you are coding. There are many edge cases where this occurs and for each one the parser will need to be updated to understand such an edge case. This is one reason why strongly typed querying is much better."
Using DAMP with the new API?
Hi,
I'm trying to use DAMP with umbraco v6 and I'm struggling to find any examples of how DAMP works with the new API? Are there any examples floating about?
At the moment I'm really struggling with working out how to get the first image in a collection using razor...
Thanks
Hi,
The V6 API is about creating content and media. When you mean new API, I think you are talking about MVC Razor views? Those are news since 4.10 and not v6 ;-).
Have a look at the DAMP Gallery. That shows how you can use DAMP in Razor.
Jeroen
Thanks Jeroen, that page is exactly what I'm looking at right now :-)
I'm having difficulty retrieving the values though - I've had to configure the data type so it stores the Ids (it's the only way I can get it to work with my installation) yet I can't seem to get any data out.
Using your example, I've tried this:
..but clearly this isn't working. Am I on the right track? The gallery example doesn't seem to show how to get an image at an index?
Thanks
Why do you want to get an image by index? Currently you're only getting a csv if you do "dynamic i = CurrentPage.backgroundImages" so "i[0].umbracoFile" also won't work. It's different from dynamic xml in the old Razor macro's.
If you have the DAMP Property Editor Value Converter installed you can do this:
It's better to do it strongly typed.
So something like this:
Jeroen
If you want to use DAMP with CropUp you could use these extension methods: http://our.umbraco.org/projects/backoffice-extensions/digibiz-advanced-media-picker/digibiz-advanced-media-picker/42181-Accessing-crops-in-DAMP25-with-CropUp-in-UmbV611-MVC#comment153505
Jeroen
Hello,
Did any of my examples help you?
Jeroen
^ we too are using our own extension methods to work with DAMP crops in a standardised manner. It would be great to see DAMP itself have these sorts of helper methods.
That's what the DAMP Property Editor Value Converter is supposed to do, but you can also create your own extension methods if you like.
Jeroen
ok cool, thanks for the info. Thats a separate package from DAMP though, correct? and it also means using 'dynamic' and our preference is for strongly-typed extensions which is why we've rolled our own.
Hi Jeroen,
Thanks for all your help - I've got everything working now :-)
Yes it's a separate package. You can also use it strongly typed (which I'm doing myself). See this example:
Single image:
Multiple images:
Jeroen
Hi, thought I'd add a little tip - define DAMP as an alias at the top of the file so that the generic type parameter is shorter, and there's no confusion about which Model is Model:
Hi,
In installed DAMP 2.5 and DAMP Property Value Converter 1.2 on my Umbraco 6.1.5 website.
It's my first Umbraco MVC site, so this is a bit new to me.
I tried to show an image stored with DAMP on my page like this:
<img alt="Browser-window-2" src="@CurrentPage.section1Image" />
But the image isn't rendered on the page. When I look in the source code of the page I see this:
<img alt="Browser-window-2" src="DAMP.PropertyEditorValueConverter.Model">
What am I doing wrong?
Thanks for your help,
Anthony
That's because @CurrentPage.section1Image is of the type DAMP.PropertyEditorValueConverter.Model. If you want to show the url of the first selected image you can try this:
Jeroen
Oh I see,
Thanks a lot Jeroen. Very convenient this DAMP Property Value Converter : )
You are using the dynamic version and I recommand the strongly typed version: http://our.umbraco.org/projects/backoffice-extensions/digibiz-advanced-media-picker/digibiz-advanced-media-picker/43984-Using-DAMP-with-the-new-API?p=0#comment158436
On the package page you can see which properties are available: http://our.umbraco.org/projects/backoffice-extensions/damp-property-editor-value-converter
Jeroen
I pushed the big green download button on this page
http://our.umbraco.org/projects/backoffice-extensions/damp-property-editor-value-converter
Which version should I use then? ( the link you gave in your previous post just goes to this forum thread )
You downloaded the correct version, but in your example you use the dynamic features of Umbraco (@CurrentPage) and it's better to use the strongly typed version (@Model.Content). You can read more about it here: http://our.umbraco.org/documentation/Reference/Mvc/querying
"Some complex queries cannot be written dynamically because the dynamic query parser may not understand precisely what you are coding. There are many edge cases where this occurs and for each one the parser will need to be updated to understand such an edge case. This is one reason why strongly typed querying is much better."
Jeroen
Oh I see, thanks a lot for the tip. As I said, Umbraco MVC is still a bit new to me, but I'm loving it so far.
is working on a reply...