示例#1
0
		/// <summary>
		/// Gets the current sitemap structure.
		/// </summary>
		/// <returns>The sitemap</returns>
		public static SiteMap Get() {
			var sitemap = App.ModelCache.GetSiteMap();

			if (sitemap == null) {
				sitemap = new SiteMap();

				using (var api = new Api()) {
					var now = DateTime.Now;

					var items = api.Pages.Get(where: p => p.Published <= now).Select(p => new SiteMapItem() {
						Id = p.Id,
						ParentId = p.ParentId,
						SortOrder = p.SortOrder,
						Title = p.Title,
						NavigationTitle = p.NavigationTitle,
						IsHidden = p.IsHidden,
						Slug = p.Slug
					}).OrderBy(p => p.ParentId).ThenBy(p => p.SortOrder).ToList();

					sitemap.Items = Sort(items, null);
				}
				App.ModelCache.SetSiteMap(sitemap);
			}
			return sitemap;
		}