Copied to clipboard

Flag this post as spam?

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


  • Nicky Christensen 76 posts 166 karma points
    Oct 06, 2012 @ 14:25
    Nicky Christensen
    0

    for() problem maybe?

    Hey guys...

    Im trying to make a list of products, and for each fourth product I want a <div class="row">

    However, it's not working, when im saving the razor file, I dont get any errors, but when watching the page, i get an error messag: Error loading MacroEngine script (file: FitnessListShopItems.cshtml)

    Any ideas to whats wrong?

    This is the code:

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @{var param = @Parameter.FolderID;}

    @{
      var N = 4;
      for(var children = Model.NodeById(param).Children.Where("NodeTypeAlias == \"FitnessShopItem\"").Children;
          children.Any();
          children = children.Skip(N))
      {
       <div class="row">
         @foreach(var child in children.Take(N))
         {
            <div class="col">
             <div class="wrap-col">
               <div class="shop-image">
                 <img alt="@children.Name" title="@children.Name" src='@children.Media("fitnessShopImage", "umbracoFile")' />
               </div>
               <umbraco:Macro Alias="FitnessImage" runat="server"></umbraco:Macro>
               <div class="shoptext">
                 @children.shopContent
               </div>
               <div class="price">
                 @children.price
               </div>
               <a href="@children.shopLink">Køb nu</a>
             </div>
           </div>
         }
        </div>
      }
    }

  • Nicky Christensen 76 posts 166 karma points
    Oct 06, 2012 @ 14:57
    Nicky Christensen
    0

    EDIT:

    I've tried changing it into this, but it's like its not even getting into the first foreach loop, as it not outputting the <div class="row">

     

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @using umbraco.MacroEngines;

    @{var param = @Parameter.FolderID;}

     

    @foreach (var group in Model.NodyById(param).Children.InGroupsOf(4))

    {

        <div class="row">

        @foreach (var item in group)

        {

            <div class="col">

               <div class="wrap-col">

                 <div class="shop-image">

                   <img alt="@item.Name" title="@item.Name" src='@item.Media("fitnessShopImage", "umbracoFile")' />

                 </div>

                 <umbraco:Macro Alias="FitnessImage" runat="server"></umbraco:Macro>

                 <div class="shoptext">

                   @item.shopContent

                 </div>

                 <div class="price">

                   @item.price

                 </div>

                 <a href="@item.shopLink">Køb nu</a>

               </div>

             </div>            

        }

        </div>

    }

  • Sebastiaan Janssen 5044 posts 15475 karma points MVP admin hq
    Oct 06, 2012 @ 15:04
    Sebastiaan Janssen
    0

    Have you checked it the parameter is passing through correctly? So what does it display if you add <span>@param</span> under @{var param = @Parameter.FolderID;} ? 

    Also, add ?umbDebugShowTrace=true to the querystring to see if there's any errors (you have to have umbracoDebugMode set to true in the web.config for this to work).


  • Nicky Christensen 76 posts 166 karma points
    Oct 06, 2012 @ 15:25
    Nicky Christensen
    0

    Ahhhh, my bad...

    Somehow all the items in the folder was unpublished, then of course it couldnt output any items... Doh! :)

  • Sebastiaan Janssen 5044 posts 15475 karma points MVP admin hq
    Oct 06, 2012 @ 15:26
    Sebastiaan Janssen
    0

    No problem, at least you got to learn about InGroupsOf and simplify your code! :-)

Please Sign in or register to post replies

Write your reply to:

Draft