Working with a Page in the Ingeniux Dynamic Site Server API
The ICMSPage object represents a physical page file within the DSS. The "Content" property of the object is a fully expanded XElement, ready to be used in standard XML fashion.
As with an XElement object, we can perform query statements directly on methods such as Attribute\Attributes, Element\Elements, and Descendants\DescendantsOrSelf. All enumerations are deferred executions, so try to leave the collection as an IEnumerable until final enumeration.
Xpath select can also be used, but it's quite a bit slower.
... var page = pageFactory.GetPage(Request); ////////////////////////////////////////////////////////////////////////////////////////////////////////// //Example: retrieving an image element (direct child) ////////////////////////////////////////////////////////////////////////////////////////////////////////// var featuredImage = page.Element("FeaturedImage"); ////////////////////////////////////////////////////////////////////////////////////////////////////////// //Example: retrieving a Navigation element with the name "AncestorNavigation" ////////////////////////////////////////////////////////////////////////////////////////////////////////// var anav = page.GetNavigation("AncestorNavigation"); ////////////////////////////////////////////////////////////////////////////////////////////////////////// //Example: recursively searching for an "SEUURL" element with a value starting with "https", //and getting the first three ////////////////////////////////////////////////////////////////////////////////////////////////////////// var seuUrls = page.Descendants("SEUURL") .Where( ele => ele.Value.StartsWith("https")) .Take(3); ////////////////////////////////////////////////////////////////////////////////////////////////////////// //Example: getting all pages assigned to the category "News" in the Taxonomy Navigation "Categorized", //and searching for the navigation recursively ////////////////////////////////////////////////////////////////////////////////////////////////////////// var taxonomyNav = page.GetTaxonomyNavigation("Categorized", true); //Notice that we are using the method ToNullHelper. This method will return a NullHelper object, //which helps create a seamless flow of query statements and type conversion //and provides for easy handling of null values at every step. //It is an extension method in Ingeniux support libraries. var category = taxonomyNav.ToNullHelper().Propagate( taxNav => taxNav.NavigatingCategories.Where( cat => cat.Name == "News").FirstOrDefault()) .Return(); var newsPages = category.ToNullHelper().Propagate( cat => cat.Pages) .Return(); ////////////////////////////////////////////////////////////////////////////////////////////////////////// //Example: getting the odd link elements in the list of links named "Related" ////////////////////////////////////////////////////////////////////////////////////////////////////////// var oddLinks = page.GetLinkItems("Related").SkipWhile((ele, index) => index % 2 == 0);
The ViewMode property is used to identify the mode of rendering. Set it as part of the model to be passed in to subviews, so that the view template can render markup that's appropriate to the view mode.
The Tag property is used to attach additional information to the page object. It's useful for integration projects.
Request information is attached directly to ICMSPage objects via the QueryString, Form, Cookies, and ServerVariables properties.
Please note that the request information properties members could be simulated, especially in preview mode. So stick to these properties when getting request information, instead of using the HTTP Request object directly.