diff options
author | haertl.mike <> | 2009-01-09 09:55:01 +0000 |
---|---|---|
committer | haertl.mike <> | 2009-01-09 09:55:01 +0000 |
commit | e0e1b84994cc78beeda17543a50c4f78514a3734 (patch) | |
tree | 6257e50bc56de6701dc4f94b83c0bcc9d56171b4 /demos/quickstart | |
parent | fd4b2bffc430cb761ea0d54d19f5d1acd184a1c6 (diff) |
Added wildcard examples to QST
Diffstat (limited to 'demos/quickstart')
-rw-r--r-- | demos/quickstart/protected/pages/Configurations/UrlMapping.page | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/demos/quickstart/protected/pages/Configurations/UrlMapping.page b/demos/quickstart/protected/pages/Configurations/UrlMapping.page index ec393012..bdd0b81d 100644 --- a/demos/quickstart/protected/pages/Configurations/UrlMapping.page +++ b/demos/quickstart/protected/pages/Configurations/UrlMapping.page @@ -111,6 +111,48 @@ object. For example, <tt>$this->Request['year']</tt>. in particular order. For example, placing the most specific mappings first.
</p>
+<p class="block-content">Since version 3.1.4, Prado also provides wildcard patterns to use friendly URLs
+for a bunch of pages in a directory with a single rule. Therefore you can use the <tt>{*}</tt> wildcard
+in your pattern to let Prado know, where to find the ServiceID in your request URL. You can also specify
+parameters with these patterns if a lot of pages share common parameters.</p>
+
+<com:TTextHighlighter Language="xml" CssClass="source block-content">
+<url ServiceParameter="Posts.*" pattern="posts/{*}/{id}" parameters.id="\d+" />
+<url ServiceParameter="Posts.*" pattern="posts/{*}" />
+<url ServiceParameter="Static.Info.*" pattern="info/{*}" />
+</com:TTextHighlighter>
+
+<p class="block-content">With these rules, any of the following URLs will be recognized:
+<ul id="u1" class="block-content">
+ <li><tt>/index.php/post/ViewPost/123</tt> is recognized as <tt>/index.php?page=Posts.ViewPost&id=123</tt></li>
+ <li><tt>/index.php/post/ListPost/123</tt> is recognized as <tt>/index.php?page=Posts.ListPost&id=123</tt></li>
+ <li><tt>/index.php/post/ListPost/123</tt> is recognized as <tt>/index.php?page=Posts.ListPost&id=123</tt></li>
+ <li><tt>/index.php/post/MyPost</tt> is recognized as <tt>/index.php?page=Posts.MyPost</tt></li>
+ <li><tt>/index.php/info/Conditions</tt> is recognized as <tt>/index.php?page=Static.Info.Conditions</tt></li>
+ <li><tt>/index.php/info/About</tt> is recognized as <tt>/index.php?page=Static.Info.About</tt></li>
+</ul>
+</p>
+
+<p>As above, put more specific rules before more common rules as the first matching rule will be used.</p>
+
+<p>To make configuration of friendly URLs for multiple pages even easier, you can also use <tt>UrlFormat="Path"</tt>
+in combination with wildcard patterns. In fact, this feature only is available in combination with wildcard rules:</P>
+
+<com:TTextHighlighter Language="xml" CssClass="source block-content">
+<url ServiceParameter="user.admin.*" pattern="admin/{*}" UrlFormat="Path"/>
+<url ServiceParameter="*" pattern="{*}" UrlFormat="Path" />
+</com:TTextHighlighter>
+
+<p class="block-content">Parameters will get appended to the specified patterns as name/value pairs, separated by a "/".
+(You can change the separator character with <tt>UrlParamSeparator</tt>.)
+<ul id="u1" class="block-content">
+ <li><tt>/index.php/list/cat/15/month/12</tt> is recognized as <tt>/index.php?page=list&cat=15&month=12</tt></li>
+ <li><tt>/index.php/edit/id/12</tt> is recognized as <tt>/index.php?page=list&id=12</tt></li>
+ <li><tt>/index.php/show/name/foo</tt> is recognized as <tt>/index.php?page=show&name=foo</tt></li>
+ <li><tt>/index.php/admin/edit/id/12</tt> is recognized as <tt>/index.php?page=user.admin.edit&id=12</tt></li>
+</ul>
+</p>
+
<h2 id="46024">Constructing Customized URLs</h2>
<p id="230233" class="block-content">
Since version 3.1.1, <tt>TUrlMapping</tt> starts to support constructing customized URLs based on the provided patterns. To enable this feature, set <tt>TUrlMapping.EnableCustomUrl</tt> to true. When <tt>THttpRequest.constrcutUrl()</tt> is invoked, the actual URL construction work will be delegated to a matching <tt>TUrlMappingPattern</tt> instance. It replaces the parameters in the pattern with the corresponding GET variables passed to <tt>constructUrl()</tt>.
|