Copied to clipboard

Flag this post as spam?

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


  • René 327 posts 852 karma points
    Dec 19, 2013 @ 00:12
    René
    0

    Show image with DAMP

    Hi 

    Umbraco v6.1.6

    Digibiz Advanced Media Picker 2.7 (DAMP 2.7)

    DAMP Property Editor Value Converter 1.2
    I´m trying to get an image to show... I have this code to show an image from the childpage. 
    @using DAMP = DAMP.PropertyEditorValueConverter.Model;
    
    @{
        var images = Model.Content.Children.GetPropertyValue<DAMP>("@childPage.image");
        var firstImage = images.first;
    }
    
    <img width="540" height="374" alt="@childPage.header" src="@firstImage.Url" />
    

     

    When i test the DAMP with this

    @childPage.image

    I get the id of the chosen images: 1114,1113,1112,1111

    Any suggestions, what i´m doing wrong.

    I have been looking to the "DAMP 2.0 Samples" :-)

    René

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Dec 19, 2013 @ 09:28
    Jeroen Breuer
    0

    I don't understand the following code completely. Can you show the complete Razor file and explain what you are trying to do?

    Jeroen

  • René 327 posts 852 karma points
    Dec 19, 2013 @ 12:27
    René
    0

    Hi Jeroen

    Of cource.. it was late when i wrote the question. 

    Im trying to get an image from the subpage. 

    It is a shop, and there are this structure:

    Shop
    - Category
    -- Product

    On the product site i have a Advanced Media Picker where i can choose 4 images. I want the first image, to be shown in the list of products, in the category.

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using DAMP = DAMP.PropertyEditorValueConverter.Model;
    
    
    @{
        var images = Model.Content.Children.GetPropertyValue<DAMP>("@childPage.image");
        var firstImage = images.first;
    }
    
    @* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@
    @if (Model.Children.Where("Visible").Any())
    {
            <div id="isotopeContainer" class="isotope-container">      
            @* For each child page under the root node, where the property umbracoNaviHide is not True *@
            @foreach (var childPage in Model.Children.Where("Visible"))
            {
                <div class="span3 isotope--target filter--suits" data-price="@childPage.price" data-popularity="1" data-size="m|l|xl" data-color="pink" data-brand="s-oliver">
                                    <div class="product">
    
                                            <div class="stamp green">@childPage.image</div>
    
                                        <div class="product-img">
                                            <div class="picture">
                                                <img width="540" height="374" alt="@childPage.header" src="@firstImage.Url" />
                                                <div class="img-overlay">
                                                    <a class="btn more btn-primary" href="@childPage.Url">Mere</a>
                                                    <a class="btn buy btn-danger" href="#">Læg i kurv</a>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="main-titles no-margin">
                                            <h4 class="title">@childPage.price</h4>
                                            <h5 class="no-margin isotope--title"><a href="@childPage.Url">@childPage.Name</a></h5>
                                        </div>
                                        <div class="row-fluid hidden-line">
                                            <div class="span6">
                                                <a href="#" class="btn btn-small"><i class="icon-heart"></i></a>
                                                <a href="#" class="btn btn-small"><i class="icon-exchange"></i></a>
                                            </div>
                             <div class="span6 align-right">
                                 <span class="icon-star stars-clr"></span>
                                 <span class="icon-star"></span>
                                 <span class="icon-star"></span>
                                 <span class="icon-star"></span>
                                 <span class="icon-star"></span>
                             </div>
                        </div>
                    </div>
                </div>
    
            }
        </div>
    }
     
    René
  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Dec 19, 2013 @ 13:02
  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Dec 19, 2013 @ 13:03
    Jeroen Breuer
    0

    The DAMP Gallery might help although it's a bit outdated.

    Jeroen

  • René 327 posts 852 karma points
    Dec 22, 2013 @ 09:07
    René
    0

    Hi Joeren 

    No i got it working. 

    The previus Umbraco sites i have made, i have only used XSLT, but for this i desided to use razor.

    Wow.. i got confused. There are different types for almoast each version of umbraco (Please correct me if im wrong!)

    One goes from Umbraco version 4.7 > 4.10 

    and there are a new one from 4.10 > 6.0 

    And a new way of doing it in 6.0 >

    It would be great in the wiki and documentation to clearly say witch version it is related to :-).

    If this could help any one, here is my working code.

    @using umbraco.MacroEngines
    @using umbraco.cms.businesslogic.media;
    @using umbraco.BusinessLogic;
    @inherits umbraco.MacroEngines.DynamicNodeContext
    
    @* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@
    @if (Model.Children.Where("Visible").Any())
    {
    <div id="isotopeContainer" class="isotope-container">      
    @* For each child page under the root node, where the property umbracoNaviHide is not True *@
    @foreach (var childPage in Model.Children.Where("Visible"))
    {
    <div class="span3 isotope--target filter--suits" data-price="@childPage.price" data-popularity="1" data-size="m|l|xl" data-color="pink" data-brand="s-oliver">
        <div class="product">
    
            <div class="stamp green">Sale</div>
    
                <div class="product-img">
                    <div class="picture">
    
                @if(childPage.HasValue("catImage")&& childPage.image.Count() > 0){
                var image = @childPage.catImage.mediaItem[0].Image.umbracoFile;
                        <img src="@image" alt="@childPage.header" width="540" height="374"/>
                }else if(childPage.catImage == ""){
                    <img src="/default.jpg" alt="autostyle missing image" width="540" height="374"/>
    } <div class="img-overlay"> <a class="btn more btn-primary" href="@childPage.Url">Mere</a> <a class="btn buy btn-danger" href="#">Læg i kurv</a> </div> </div> </div> <div class="main-titles no-margin"> <h4 class="title">@childPage.price</h4> <h5 class="no-margin isotope--title"><a href="@childPage.Url">@childPage.Name</a></h5> </div> <div class="row-fluid hidden-line"> <div class="span6"> <a href="#" class="btn btn-small"><i class="icon-heart"></i></a> <a href="#" class="btn btn-small"><i class="icon-exchange"></i></a> </div> <div class="span6 align-right"> <span class="icon-star stars-clr"></span> <span class="icon-star"></span> <span class="icon-star"></span> <span class="icon-star"></span> <span class="icon-star"></span> </div> </div> </div> </div> } </div> }

     René

Please Sign in or register to post replies

Write your reply to:

Draft