Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dan White 206 posts 510 karma points c-trib
    Dec 06, 2012 @ 18:42
    Dan White
    0

    DAMP with MVC views in 4.11

    Ok. I've recently discovered this package and it's freaking amazing. However, I'm a complete newb. I'm really struggling(for hours) to figuring out how to work with DAMP and 4.11 MVC views.

    Model.Content.GetPropertyValue("dampNewWide");

    and 

    Model.Content.GetProperty("dampNewWide").Value;

    Are returning different things. The first returns an object that I can't seem to perform anything actions on. The second returns a string of the XML. From the 4.10 documention, I would expect both to return the same thing.

    I can't iterate over either one. 

    CurrentPage.dampNewWide;

    Returns something similar to the first mentioned, except I can iterate over it.

        foreach(var d in CurrentPage.dampNewWide){
            var x = d.ImageWide.umbracoFile;
            @x; //spits out path to image
        }

     

    So:
    Why can't I perform any actions to the value returned by Model.Content?

    Can anyone provide some more insight these things in general?

    It would be fantastic if there were some best practice examples for MVC views in the DAMP Samples package.

    Any help would be greatly appreciated. I'm working on my first real Umbraco site.

     

     

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Dec 06, 2012 @ 18:45
    Jeroen Breuer
    101

    If you want to use DAMP in 4.11 MVC it's better to use the DAMP Property Editor Value Converter. You can watch a demo here: http://www.screenr.com/g2H7

    Jeroen

  • Lennart Stoop 304 posts 842 karma points
    Dec 06, 2012 @ 20:40
    Lennart Stoop
    0

    Hmm I didn't know about that package Jeroen, I will give it a try as well. 

    Since I wasn't sure about the exact Razor syntax either I had been using Linq 2 XML to fetch the image paths.

    @using System.Xml.Linq;
    XDocument.Parse(contentBlocksNode.GetProperty("defaultImages").Value).Descendants("umbracoFile")
  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Dec 10, 2012 @ 10:16
    Jeroen Breuer
    1

    Hello,

    I've released the DAMP gallery. It's a website which shows how DAMP can be used in 4.11 MVC for an image and video gallery. The complete source code is available so you can see exactly how things are working.

    Jeroen

  • Dan White 206 posts 510 karma points c-trib
    Dec 12, 2012 @ 21:39
    Dan White
    0

    Awesome. Thanks @Jeroen

  • Keith R Hubbard 175 posts 403 karma points
    May 15, 2013 @ 07:27
    Keith R Hubbard
    0

    I wish @Jeroen you had an example without paging

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    May 15, 2013 @ 09:47
    Jeroen Breuer
    0

    It's pretty simple. In the example it says this:

    @foreach (dynamic d in i.Skip(p.CurrentPage * p.ItemsPerPage).Take(p.ItemsPerPage)) { <li> <a class="popup" rel="gallery" href="@d.Url"> <img src="@d.Crops.gallery" alt="@d.Alt"/> </a> </li> }

    Just remove the skip an take part to get all the images:

    @foreach (dynamic d in i) { <li> <a class="popup" rel="gallery" href="@d.Url"> <img src="@d.Crops.gallery" alt="@d.Alt"/> </a> </li> }

    Jeroen

  • Keith R Hubbard 175 posts 403 karma points
    May 15, 2013 @ 22:41
    Keith R Hubbard
    0

    I just want to get a crop to work in 4,11.  it is Krazy how it worked before but not in MVC except in your examples.  Sorry but it is frustrating.

    I have a department image and I just want to list with a

     

    //Get the images selected with DAMP. dynamic departmentImage = CurrentPage.Children.imageDepartment; if (departmentImage.Count > 0) {

    }

    }

  • Keith R Hubbard 175 posts 403 karma points
    May 23, 2013 @ 05:12
    Keith R Hubbard
    0

    Jeroen

    I have tried to reduplicate your Damp Gallery on V4.11.8 and V6.05 with the same result.  A 404 error on video and a problem with paging on Gallery1.  Any ideas Link incuded below. 

    http://htiek.com/youtube-gallery.aspx

     

    Thanks

    Keith Hubbard

Please Sign in or register to post replies

Write your reply to:

Draft