<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Page Definition and URL Routing</title><link>https://community.telligent.com/community/11/w/developer-training/65062/page-definition-and-url-routing</link><description /><dc:language>en-US</dc:language><generator>14.0.0.586 14</generator><item><title>Page Definition and URL Routing</title><link>https://community.telligent.com/community/11/w/developer-training/65062/page-definition-and-url-routing</link><pubDate>Thu, 13 Jun 2019 19:23:57 GMT</pubDate><guid isPermaLink="false">7ededb7d-c43e-458a-863a-4affde8336c4</guid><dc:creator>Ben Tiedt</dc:creator><comments>https://community.telligent.com/community/11/w/developer-training/65062/page-definition-and-url-routing#comments</comments><description>Current Revision posted to Developer Training by Ben Tiedt on 06/13/2019 19:23:57&lt;br /&gt;
&lt;p&gt;Custom functionality may require that URLs be defined that can be referenced by code to enable specific workflows (editing content, viewing content, listing content, etc). New pages can be declared in code&amp;nbsp;at custom routed URLs to provide&amp;nbsp;reliable URLs for specific functionality to custom plugins and UI extensions.&lt;/p&gt;
&lt;p&gt;[toc]&lt;/p&gt;
&lt;h2&gt;&lt;a id="Routed_Pages_vs_Custom_Pages" name="Routed_Pages_vs_Custom_Pages"&gt;&lt;/a&gt;Routed Pages vs. Custom Pages&lt;/h2&gt;
&lt;p&gt;Custom pages are useful for custom UI specific to a single blog, group, or site that is not required as part of a larger application. When a page/URL must exist to enable a workflow, a routed page may be a better option. The table below shows all differences between routed pages and custom pages:&lt;/p&gt;
&lt;table style="height:223px;" width="443"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align:center;"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td style="text-align:center;"&gt;Routed Pages&lt;/td&gt;
&lt;td style="text-align:center;"&gt;Custom Pages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left;"&gt;Supports parsing the URL into a programmatic context&lt;/td&gt;
&lt;td style="text-align:center;"&gt;Yes&lt;/td&gt;
&lt;td style="text-align:center;"&gt;
&lt;p&gt;No&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left;"&gt;Defined within a specific theme instance (a single blog, group, site, etc)&lt;/td&gt;
&lt;td style="text-align:center;"&gt;No&lt;/td&gt;
&lt;td style="text-align:center;"&gt;
&lt;p&gt;Yes&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left;"&gt;Has a factory default implementation&lt;/td&gt;
&lt;td style="text-align:center;"&gt;Yes&lt;/td&gt;
&lt;td style="text-align:center;"&gt;
&lt;p&gt;No&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left;"&gt;Created&amp;nbsp;in code&lt;/td&gt;
&lt;td style="text-align:center;"&gt;Yes&lt;/td&gt;
&lt;td style="text-align:center;"&gt;
&lt;p&gt;No&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left;"&gt;Created&amp;nbsp;in&amp;nbsp;the user interface&lt;/td&gt;
&lt;td style="text-align:center;"&gt;No&lt;/td&gt;
&lt;td style="text-align:center;"&gt;
&lt;p&gt;Yes&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left;"&gt;Requires /p/ in URL path&lt;/td&gt;
&lt;td style="text-align:center;"&gt;No&lt;/td&gt;
&lt;td style="text-align:center;"&gt;
&lt;p&gt;Yes&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;&lt;a id="Defining_Site_Pages" name="Defining_Site_Pages"&gt;&lt;/a&gt;Defining Site Pages&lt;/h2&gt;
&lt;p&gt;The &lt;a href="/developers/w/developer90/50299.inavigable-plugin-type"&gt;INavigable&lt;/a&gt;&amp;nbsp;Plugin type is used to define routed&amp;nbsp;site pages. &amp;nbsp;In addition to the base &lt;a title="IPlugin" href="/developers/w/developer90/50307.iplugin-plugin-type"&gt;IPlugin&lt;/a&gt; members, INavigable adds the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;void RegisterUrls(IUrlController controller);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The RegisterUrls method provides a reference to the &lt;a href="/developers/w/developer90/50192.iurlcontroller-plugin-supplementary-type"&gt;IUrlController&lt;/a&gt;. &amp;nbsp;The controller allows you to&amp;nbsp;register urls with the&amp;nbsp;platform.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Example_1_Site_Page" name="Example_1_Site_Page"&gt;&lt;/a&gt;Example 1: &amp;nbsp;Site Page&lt;/h3&gt;
&lt;p&gt;The Site Page example will create a blank page at the root of the site with the URL &amp;quot;custom.&amp;quot; &amp;nbsp;For example, if your community URL&amp;nbsp;was &amp;nbsp;http://mycommunity,&amp;nbsp;the new page would be found at http://community/custom.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/5518_2E00_CustomSitePageExample_2E00_cs"&gt;community.telligent.com/.../5518_2E00_CustomSitePageExample_2E00_cs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;We use the controller.AddPage method to add a new widget page. &amp;nbsp;For additional information on the IUrlController and its methods see the &lt;a href="/developers/w/developer90/50192.iurlcontroller-plugin-supplementary-type"&gt;IUrlController&lt;/a&gt;&amp;nbsp;documentation.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Example_2_Members_Page" name="Example_2_Members_Page"&gt;&lt;/a&gt;Example 2: Members Page&lt;/h3&gt;
&lt;p&gt;The Members page&amp;nbsp;adds a page for each user on the site at&amp;nbsp;http://mycommunity/{username}/custompage. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/3051_2E00_CustomUserPageExample_2E00_cs"&gt;community.telligent.com/.../3051_2E00_CustomUserPageExample_2E00_cs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In this example the Url parameter is defined as &lt;em&gt;&amp;quot;members/{UserName}/custompage&amp;quot;&lt;/em&gt;, the&lt;em&gt; &amp;nbsp;new { UserName = @&amp;quot;^[a-zA-Z0-9\-\._]+$&amp;quot; } &lt;/em&gt;constraint has also been applied to the UserName variable. &amp;nbsp;The Url will only respond if the requested Url matches the format and constraints that are defined when adding the page.&lt;/p&gt;
&lt;p&gt;The example also uses some of the options available in the &lt;a href="/developers/w/developer90/50208.pagedefinitionoptions-plugin-supplementary-type"&gt;PageDefinitionOptions&lt;/a&gt;&amp;nbsp;parameter. &amp;nbsp;DefaultPageXml is used to define the factory default set of widgets for this page. &amp;nbsp;The TitleFunction and DescriptionFunction options determine the page&amp;#39;s name and description when working with the page in the theme editing panels. &amp;nbsp;ParseContext defines the method that is used to examine the Url and determine what item are in context for this page. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;The ParseContext method in the example performs a few functions. &amp;nbsp;First we attempt to load the username from the URL. &amp;nbsp;If it&amp;#39;s valid, we add that user to the page&amp;#39;s ContextItems collection. This in turn enables other methods in the platform. &amp;nbsp;For instance, having a user in the ContextItems collection allows the $core_v2_user.Current velocity call to return that user. &amp;nbsp;If the user is not valid we either redirect the user to login to the site if they are not currently logged in or we throw an exception identifying the username to be invalid.&lt;/p&gt;
&lt;h2&gt;&lt;a id="Defining_Application_Pages" name="Defining_Application_Pages"&gt;&lt;/a&gt;Defining Application Pages&lt;/h2&gt;
&lt;p&gt;The &lt;a href="/developers/w/developer90/50247.iapplicationnavigable-plugin-type"&gt;IApplicationNavigable&lt;/a&gt;&amp;nbsp;Plugin type is used to extend existing applications (and groups) by adding new routed pages. &amp;nbsp;In addition to the base &lt;a title="IPlugin" href="/developers/w/developer90/50307.iplugin-plugin-type"&gt;IPlugin&lt;/a&gt; members, IApplicationNavigable adds the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void RegisterUrls(IUrlController controller);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The RegisterUrls method provides a reference to the &lt;a href="/developers/w/developer90/50192.iurlcontroller-plugin-supplementary-type"&gt;IUrlController&lt;/a&gt;. &amp;nbsp;The controller allows you to&amp;nbsp;register urls with the&amp;nbsp;platform.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Guid ApplicationTypeId { get; }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The ApplicationTypeId&amp;nbsp;property specifies which application type will display the new page.&amp;nbsp;&lt;/p&gt;
&lt;h3&gt;&lt;a id="Example_3_Blog_Raw_Page" name="Example_3_Blog_Raw_Page"&gt;&lt;/a&gt;Example 3: Blog Raw Page&lt;/h3&gt;
&lt;p&gt;This sample adds a url to a blog that is handled by an IHttpHandler. &amp;nbsp;The page defined in the sample would have the following URL&amp;nbsp;pattern:&amp;nbsp;http://community/{grouppath}/{b}/{blogappkey}/raw.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.telligent.com/cfs-file/__key/communityserver-wikis-components-files/00-00-00-12-83/5127_2E00_CustomBlogRawExample_2E00_cs"&gt;community.telligent.com/.../5127_2E00_CustomBlogRawExample_2E00_cs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;URL&amp;nbsp;is defined as &lt;em&gt;{WeblogApp}/raw&lt;/em&gt;, since we are adding a page to the blog application, the portion of the URL up to and including the&amp;nbsp;blog application identifier (&amp;#39;&lt;em&gt;/b/&amp;#39;) &lt;/em&gt;accounted for. &amp;nbsp;You are only required to define the portion of the url inside the group or application.&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;a id="What_is_the_difference_between_adding_a_widget_page_and_adding_a_raw_page" name="What_is_the_difference_between_adding_a_widget_page_and_adding_a_raw_page"&gt;&lt;/a&gt;What is the difference between adding a widget page and adding a raw page?&lt;/h2&gt;
&lt;p&gt;The&amp;nbsp;IUrlController provides the option to add a widget page or a raw page. &amp;nbsp;A widget page is a themeable page that supports a&amp;nbsp;widget-based layout. &amp;nbsp;Raw pages give complete control over the output when defining the Url. &amp;nbsp;The typical use case for raw pages are RSS Feeds, file downloads or Xml.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: inavigable, IApplicationNavigable&lt;/div&gt;
</description></item></channel></rss>