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 @ 17:01
    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). 

    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 within an mvc template. The other properties such as date and price work correctly. 

    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. 

    @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. 

Please Sign in or register to post replies

Write your reply to:

Draft