Copied to clipboard

Flag this post as spam?

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


  • Richard Galt 50 posts 186 karma points
    Feb 16, 2015 @ 17:25
    Richard Galt
    0

    IsFirst giving strange results

    Hi guys,

    I've got a sliding banner that I'm having issues with. It's working correctly on my dev site but the pre go live site with an identical partial view is not setting an active item where the item IsFirst.

    Using Umbraco 7.1.6

    This is my code:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
        @using Our.Umbraco.PropertyConverters.Models
    
        @{
            var root = Model.Content.GetPropertyValue<string>("sectionName");
            var promoItems = Umbraco.ContentAtXPath("//PromoItem").Where("Visible");
    }
    
    
    <div id="myCarousel" class="carousel slide"> 
        <div class="carousel-inner">
            @foreach (var item in promoItems)
      {
      if  (item.GetPropertyValue<string>("siteAssignedTo") == root || (item.GetPropertyValue<string>("siteAssignedTo") == "All"))
      {
            <div class="@item.IsFirst("active") item">
                <div class="slide">
                    <img src="@item.GetCropUrl("image","promoHome")" alt="@item.Name" />
                        <div class="promoinfo">
                         <a href="@item.GetPropertyValue("link").Url" class="btn btn-primary"><h3>@item.GetPropertyValue("Description")</h3></a>
                    </div>
                </div>
            </div>
            }
            }
        </div>
        <!-- Carousel nav -->
            <div class="carousel-control">
        <a class="carousel-control left" href="#myCarousel" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
        <a class="carousel-control right" href="#myCarousel" data-slide="next"><span  class="glyphicon glyphicon-chevron-right"></span></a>
            </div>
    </div>
    

    Any help would be much appreciated :)

  • Jeavon Leopold 3000 posts 13161 karma points MVP 6x admin c-trib
    Feb 16, 2015 @ 18:27
    Jeavon Leopold
    1

    Hi Richard,

    You will need to use the ToContentSet method, this was a breaking change in v7.1 and v6.2 which I documented here

    e.g.

    @foreach (var item in promoItems.ToContentSet())
    

    Jeavon

  • Richard Galt 50 posts 186 karma points
    Feb 17, 2015 @ 10:06
    Richard Galt
    0

    Hi Jeavon,

    I've just tried that and it's made no difference :(

    Rich

  • Richard Galt 50 posts 186 karma points
    Feb 17, 2015 @ 16:47
    Richard Galt
    0

    I've tried a condition instead but this works for the dev site but not the pre live site. I have cleared the App_Data folder and recycled the web app but with no joy.

    New code:

        @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
            @using Our.Umbraco.PropertyConverters.Models
    
            @{
                var root = Model.Content.GetPropertyValue<string>("sectionName");
                var promoItems = Umbraco.ContentAtXPath("//PromoItem").Where("Visible");
        }
    
    
        <!--promo slider html-->
        <div id="myCarousel" class="carousel slide"> 
            <div class="carousel-inner">
                @{int count = 0;
                  string activeclass = "";}
                @foreach (var item in promoItems)
          {
              if (count == 0)
                {
                    activeclass = "active item";
                    count++;
                }
                else
                {
                    activeclass = "item";
                }
          if  (item.GetPropertyValue<string>("siteAssignedTo") == root || 
              (item.GetPropertyValue<string>("siteAssignedTo") == "All"))
          {
                <div class="@activeclass">
                    <div class="slide">
                        <img src="@item.GetCropUrl("image","promoHome")" alt="@item.Name" />
                            <div class="promoinfo">
    <a href="@item.GetPropertyValue("link").Url" class="btn btn-primary">
    <h3>@item.GetPropertyValue("Description")</h3></a>
                        </div>
                    </div>
                </div>
                }
                }
            </div>
            <!-- Carousel nav -->
                <div class="carousel-control">
            <a class="carousel-control left" href="#myCarousel" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span></a>
            <a class="carousel-control right" href="#myCarousel" data-slide="next">
    <span  class="glyphicon glyphicon-chevron-right"></span></a>
                </div>
        </div>
        <!--end promo slider html-->
    
Please Sign in or register to post replies

Write your reply to:

Draft