Copied to clipboard

Flag this post as spam?

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


  • Mark Watson 118 posts 380 karma points
    22 days ago
    Mark Watson
    0

    Rendering display issue with .Take

    The code below displays 5 items rather than 6 that I need. When I change this to 7 it displays 6 so it displays one less than specified. Just can not work out why it is doing this. Does anyone have any ideas.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    
    @{
        var selection = Umbraco.Content(Guid.Parse("800fd6f3-d5c1-498b-9e81-0dac67a85d7d"))
        .Children()
        .Where(x => x.IsVisible())
        .OrderByDescending(x => x.Value<DateTime>("pressReleaseDate"))
        .Take(6);
    }
        @foreach (var item in selection)
            {
    var typedMediaPickerSingle = item.Value<IPublishedContent>("pressReleasehomeimage");
                  if (typedMediaPickerSingle != null)
                  {
        <div class="main-news">
        <div class="newsbody">
            <div class="newsimage"><img src="@typedMediaPickerSingle.Url" /></div>
            <div class="newstext">
                               <h7> @(item.Value<DateTime>("pressReleaseDate").ToString("dddd, MMMM dd, yyyy"))</h7>
            <div class="truncate-ellipsis">
                <h5><a href="@item.Url">@item.Name</a></h5>
                </div>
    </div>
    </div></div>
    <div class="newsfooter"><img src="umbraco/assets/img/pressimage.png"></div>
        }
    
        }
    
  • Thomas Kassos 32 posts 166 karma points
    22 days ago
    Thomas Kassos
    0

    Hi, Can you confirm that non of the items of your selection don't have a null "pressReleasehomeimage" ?

  • Mark Watson 118 posts 380 karma points
    22 days ago
    Mark Watson
    0

    Thanks Thomas All items have images.

  • Thomas Kassos 32 posts 166 karma points
    22 days ago
    Thomas Kassos
    0

    Hmm not sure, maybe you can try also to amend the where with that

    .Where(x => x.IsVisible() && x.Value<IPublishedContent>("pressReleasehomeimage") != null)
    

    Just to make sure isn't any image. Can't see anything else.. :/

  • Mark Watson 118 posts 380 karma points
    14 days ago
    Mark Watson
    0

    Thanks Thomas We found that one of the images was formatted in cmyk and not rgb. When we made it rgb it worked.

Please Sign in or register to post replies

Write your reply to:

Draft