Changeset 1544
- Timestamp:
- 12/03/2006 07:21:04 AM (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/demos/quickstart/protected/pages/Configurations/UrlMapping.page
r1447 r1544 26 26 </div> 27 27 28 <p>The mapping format is as follows. 28 <p> 29 To use <tt>TUrlMapping</tt>, one must set the <tt>UrlManager</tt> property of the <tt>THttpRequest</tt> module as the <tt>TUrlMapping</tt> module ID. See following for an example, 29 30 <com:TTextHighlighter Language="xml" CssClass="source"> 30 <module id="friendly-url" class="System.Web.TUrlMapping"> 31 <url serviceParameter="ClassName" pattern="pattern" parameters.id="subpattern" /> 32 </module> 31 <modules> 32 <module id="request" class="THttpRequest" UrlManager="friendly-url" /> 33 <module id="friendly-url" class="System.Web.TUrlMapping"> 34 <url ServiceParameter="Posts.ViewPost" pattern="post/{id}/?" parameters.id="\d+" /> 35 <url ServiceParameter="Posts.ListPost" pattern="archive/{time}/?" parameters.time="\d{6}" /> 36 <url ServiceParameter="Posts.ListPost" pattern="category/{cat}/?" parameters.cat="\d+" /> 37 </module> 38 </modules> 33 39 </com:TTextHighlighter> 34 40 </p> 35 41 36 <p>The <tt>ServiceParameter</tt> and <tt>ServiceID</tt> 37 (the default ID is 'page') set the service parameter and service ID, respectively, of 38 the <a href="?page=Fundamentals.Modules">Request module</a>. 39 The service parameter for the <tt>TPageService</tt> service is the 40 Page class name, e.g., for an URL "index.php?page=Home", "page" is the service ID and the service 41 parameter is "Home". Other services may use the service parameter and ID differently. 42 See <a href="?page=Fundamentals.Services">Services</a> for further details. 42 <p> 43 The above example is part of the application configuration of the <tt>blog</tt> demo in the PRADO release. It enables recognition of the following URL formats: 44 </p> 45 <ul> 46 <li><tt>/index.php/post/123</tt> is recognized as <tt>/index.php?page=Posts.ViewPost&id=123</tt></li> 47 <li><tt>/index.php/archive/200605</tt> is recognized as <tt>/index.php?page=Posts.ListPost&time=200605</tt></li> 48 <li><tt>/index.php/category/2</tt> is recognized as <tt>/index.php?page=Posts.ListPost&cat=2</tt></li> 49 </ul> 50 51 <p> 52 The <tt>ServiceParameter</tt> and <tt>ServiceID</tt> (the default ID is 'page') set the service parameter and service ID, respectively, of the <a href="?page=Fundamentals.Modules">Request module</a>. The service parameter for the <tt>TPageService</tt> service is the Page class name, e.g., for an URL "index.php?page=Home", "page" is the service ID and the service parameter is "Home". Other services may use the service parameter and ID differently. See <a href="?page=Fundamentals.Services">Services</a> for further details. 53 </p> 54 55 <h2>Specifying URL Patterns</h2> 56 <p> 57 <tt>TUrlMapping</tt> enables recognition of customized URL formats based on a list prespecified of URL patterns. Each pattern is specified in a <tt><url></tt> tag. 43 58 </p> 44 59 … … 96 111 the URL will be used. Cascaded mapping can be achieved by placing the URL mappings 97 112 in particular order. For example, placing the most specific mappings first. 98 </p> 113 </p> 114 115 <h2>Constructing Customized URLs</h2> 116 <p> 117 Since version 3.0.6, <tt>TUrlMapping</tt> starts to support constructing customized URL formats. This is achieved by allowing users to extend <tt>TUrlMapping</tt> class and override the <tt>constructUrl</tt> method. In the applications, users can still use <tt>THttpRequest.constructUrl()</tt> or <tt>TPageService.constructUrl()</tt> to generate PRADO-recognizable URLS. The actual URL construction work is ultimately delegated to the <tt>TUrlMapping.constructUrl()</tt>, provided it is implemented. 118 </p> 99 119 100 120 </com:TContent>
