Documentation > CMS Template API Library > Util > Paginate(List[Asset],Int32)


Separates an asset list into pages, and returns a portion of the list based on the current page number (context.PageNumber) and the given itemsPerPage. This may only be used in an output template. NOTE: Page numbers are added to filenames and URLs BEFORE any filename or url templates are run. If those templates overwrite the publish path or publish URL, then the template should add the page number using the context.PageNumber property.

public CrownPeak.CMSAPI.PaginateResult Paginate(List[Asset],Int32)


List containing the items appropriate for the current page


entireList The list if assets to paginate. List<Asset>
itemsPerPage The desired number of list items per page. System.Int32

Code Example



             List<Asset> pressReleases = folder.GetFileList();
             PaginateResult result = Util.Paginate(pressReleases, 10);
             // Print links to press releases on the current page
             foreach(Asset child in result)
               Out.WriteLine("<a href=\"{0}\">{1}</a><br/>",child.GetLink(), child.Label);
             // Print links to other pages
             foreach (PageLink link in result.PaginatedLinks)
               if (link.IsCurrent())
                 Out.WriteLine("{0}|", link.PageNumber);
                 Out.WriteLine("<a href=\"{0}\">{1}</a>|", link, link.PageNumber);

Connect with Crownpeak