Copied to clipboard

Flag this post as spam?

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


  • Sören Deger 733 posts 2844 karma points c-trib
    Jan 18, 2012 @ 10:02
    Sören Deger
    0

    DAMP - Paging error (umbraco.MacroEngines.DynamicXml contains no definition for Skip)

    Hello,

    i use the DAMP advanced Media Picker and it's works very good without paging. But if I will integrate a paging then I see the following error:

    Error loading Razor Script ListGalerie.cshtml
    umbraco.MacroEngines.DynamicXml contains no definition for Skip.

    I debug the script, but i can't found the error. This is my code:

    @using HtmlAgilityPack

    @{
        if (@Model.HasValue("media"))
         {   
            dynamic mediaItems = @Model.media.mediaItem;
            var pagesToList = mediaItems;
             
            // configuration
            var numberOfItems = pagesToList.Count();
            var itemsPerPage = @Model.Parent.paging2;
          
            if (itemsPerPage==0)
            {
              itemsPerPage=numberOfItems;
            }
            var previousLabel = "zurück";
            var nextLabel = "vor";
            
            // paging calculations
            int currentPage = 1;
            if (!int.TryParse(HttpContext.Current.Request.QueryString["Page"], out currentPage)) {
              currentPage = 1;
            }
            currentPage--;
            var numberOfPages = numberOfItems % itemsPerPage == 0 ? Math.Ceiling((decimal)(numberOfItems / itemsPerPage)) : Math.Ceiling((decimal)(numberOfItems / itemsPerPage))+1;
            
       
            @* Debug beginn *@
            <p>Number of items: @numberOfItems <br />items per page: @itemsPerPage<br />current page: @currentPage<br /><br />Pages to list:</p>
            foreach (var item in pagesToList)
            {
              @item.Image.nodeName
              <br />
            }
            @* Debug end, works great! *@
          
             
            foreach (var item in pagesToList.Skip(currentPage*itemsPerPage).Take(itemsPerPage))
            {  
               
                if (mediaItems.Count() != 0)
                {

                <h2>@Model.Name</h2>

                      var image = item.Image;
                      @*Original image: <a href="@image.umbracoFile">@image.nodeName</a> (@image.umbracoBytes bytes)<br />*@
                      
                        <div class="GalerievorschauItem">
                          <img src="@image.crop.Find("@name","Vorschaubild").url" />
                        </div>
                }

            }

        }
    }

     

    Have anyone a idea?

    Umbracoversion: 4.7.1 - asp.net 4.0

     

    Sören

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jan 18, 2012 @ 10:12
    Jeroen Breuer
    0

    Well it's very simple. DynamicXml doesn't support skip or take. Maybe this will be added to 4.7.2, but for now it's best if you convert the xml to an XElement and do paging on that.

    Jeroen

  • Sören Deger 733 posts 2844 karma points c-trib
    Jan 18, 2012 @ 12:40
    Sören Deger
    0

    Thank you!

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jan 23, 2012 @ 09:33
    Jeroen Breuer
    0

    You could also try the DAMP RazorDataTypeModel. You could change the code so it returns a List of media items. Than in your Razor code you can use Skip and Take on that list. Here is more info about Razor DataType Models: http://umbraco.com/follow-us/blog-archive/2011/9/18/umbraco-razor-feature-walkthrough%E2%80%93part-7.aspx.

    Jeroen

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Nov 12, 2012 @ 13:20
    Jeroen Breuer
    0

    I created my own DAMP Razor Model you can use: http://our.umbraco.org/projects/backoffice-extensions/damp-razor-model. It also supports Skip and Take for paging :-).

    Jeroen

  • Sören Deger 733 posts 2844 karma points c-trib
    Nov 12, 2012 @ 13:36
    Sören Deger
    0

    Hi Jeroen,

    thank you! Great works! I'll try it in the coming days.

    Sören

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

    Hello,

    I've released the DAMP gallery. It's a website which shows how DAMP can be used in 4.11 MVC for an image and video gallery. The complete source code is available so you can see exactly how things are working. It also has paging in it with Skip and Take :-).

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft