Copied to clipboard

Flag this post as spam?

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


  • Dafydd Owen 33 posts 173 karma points
    Jan 05, 2014 @ 16:38
    Dafydd Owen
    0

    Child Node & DAMP Media

    Hello Umbraco Community.

    I'm hoping you can help me with some razor scripting. I have Umbraco 6.1.6 using the CWS Start" package that Warren Buckley created.

    I am trying to retrieve an image crop using the default image cropper in Umbraco from a child node. The structure of the doc types being used are;

    CWSUrlList = Parent Node
    CWSUrl = Child Node

    Each CWSUrl node includes an image which is selected via DAMP and that I want to display on the parent node page (CWSUrlList). 

    Below is the code that is just about working. I say "just about" because since removing some of the @using / @inherits calls I initially was using, the image is no longer being pulled through. 

    The crop I am trying to establish is called "dampNewWide", and has been based on the DAMP sample pack. So the Doc Type CWSUrl includes a DAMP item called "dampNewWide".

    I am trying to run the code below within an mvc template. The other properties such as date and price work correctly. 

    @foreach (var urlItem in Model.Content.Children.Where(x => x.IsVisible())) {

       
    var urlDate = @Convert.ToDateTime(urlItem.GetProperty("itemDate").Value).Date.ToString("dd MMMM yyyy");
       
    var price = urlItem.GetProperty("itemPrice").Value.ToString();  
     
    var image = urlItem.GetProperty("itemImage").Value;  
     
    var mediaItem = Umbraco.TypedMedia(image);
       
    var mediaItemComplete = mediaItem.GetPropertyValue("umbracoFile");
     
    <img src="@mediaItemComplete" alt="@mediaItem.GetPropertyValue("Name")"/>        

           
    <h3>@urlItem.Name</h3>
        <p>Listing Date:@urlDate</
    p>    
     
    <p>Price:$@price</p>
    }

     

    Any help would be greatly appreciated. 

    Dafydd

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jan 06, 2014 @ 11:01
    Jeavon Leopold
    0

    Hi Dafydd,

    You should install the DAMP Property Editor Value Converter it makes this very easy.

    There is also a samples package available http://our.umbraco.org/FileDownload?id=4718

    Jeavon

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jan 06, 2014 @ 11:05
    Jeroen Breuer
    0

    Hello,

    You could also have a look at the DAMP gallery or the Hybrid Framework for some examples.

    The sample that Jeavon points to probably doesn't work on Umbraco v6, but only on v4.

    Jeroen

  • Dafydd Owen 33 posts 173 karma points
    Jan 06, 2014 @ 11:14
    Dafydd Owen
    0

    Thanks for the response guys. 

    I have gone back to V4 for the time being but am determined to understand the new features of V6.

    I will check out all of the suggestions once I reupload the V6 version of the site later today and report back.

    Thanks again and have a great day.

    Dafydd

     

Please Sign in or register to post replies

Write your reply to:

Draft