Copied to clipboard

Flag this post as spam?

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


  • Paul Stewart 50 posts 71 karma points
    Mar 23, 2012 @ 13:33
    Paul Stewart
    0

    'umbraco.MacroEngines.DynamicXml' to 'string' (IF STATEMENT)

    Hey everyone, I am having problems of creating a If statement for my client testimonials on my page. I can get all the values from my custom media item (umbracoFile, clientName, clientTestimonial, Id)

    What i want to do is make a if statement where if the client testimonial has a value then display the following html and content. 

    Here is my razor script. Ive bold the text to show the problem I am having with

    @using umbraco;
    @using umbraco.cms.businesslogic.media;
    
    @{
        int mediaId = int.Parse(Parameter.mediaId.ToString());
    
        Media gallery = new Media(mediaId);
    
        <div class="clients">
        @foreach (dynamic banner in gallery.Children)
        {
    
            mediaId = banner.Id;
            string str_image = Model.MediaById(mediaId).umbracoFile;
    
            string alt = Model.MediaById(mediaId).clientName;
            string click = "click" + Model.MediaById(mediaId).Id;
            string id = "client" + Model.MediaById(mediaId).Id;
            string linkId = "show" + Model.MediaById(mediaId).Id;
    
    
            <div class="clientImage">
                   <img class="imageClass" id="@id" src="@str_image" tooltip="@alt" border="0" alt="LOGO: @alt" />
            </div>
        }
        </div>
        <div class="content_top"></div>
        <div id="testimonials">
        @foreach (dynamic banner in gallery.Children)
        {
            mediaId = banner.Id;
            string emptytestimonial = Model.MediaById(mediaId).clientTestimonial;
            string clientTestimonial = Model.MediaById(mediaId).clientTestimonial;
            string clientName = Model.MediaById(mediaId).clientName;
            string linkId = "show" + Model.MediaById(mediaId).Id;
            string id = "t_client" + Model.MediaById(mediaId).Id;
            if (emptytestimonial.IsEmpty())
            {
    
    
    
                <div class="itemTest" id="@id">
    
                <div class="testimonials_top">
                    <div class="testmonials_bottom">
                            <div>
                                <p>@clientTestimonial</p>
                                <span>
                                    @clientName
                                </span>
                            </div>
                    </div>
                </div>
    
                </div>
            }
        }
        </div>
    }

    If anyone could help me that would il be most thankful. am still newish to razor, trying to understand the concept of it like and how it works... 

    Thanks 

    Paul

  • Paul Stewart 50 posts 71 karma points
    Mar 23, 2012 @ 15:09
    Paul Stewart
    0

    Anyone? lol

  • Sean Dooley 289 posts 528 karma points
    Mar 28, 2012 @ 17:26
    Sean Dooley
    0

    Hi Paul

    What is actually happening with the line in question? Any error messages? Are you able to step through your code with a debugger?

Please Sign in or register to post replies

Write your reply to:

Draft