summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
Diffstat (limited to 'demos')
-rw-r--r--demos/quickstart/protected/pages/Configurations/UrlMapping.page42
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&amp;id=123</tt></li>
+ <li><tt>/index.php/post/ListPost/123</tt> is recognized as <tt>/index.php?page=Posts.ListPost&amp;id=123</tt></li>
+ <li><tt>/index.php/post/ListPost/123</tt> is recognized as <tt>/index.php?page=Posts.ListPost&amp;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&amp;cat=15&amp;month=12</tt></li>
+ <li><tt>/index.php/edit/id/12</tt> is recognized as <tt>/index.php?page=list&amp;id=12</tt></li>
+ <li><tt>/index.php/show/name/foo</tt> is recognized as <tt>/index.php?page=show&amp;name=foo</tt></li>
+ <li><tt>/index.php/admin/edit/id/12</tt> is recognized as <tt>/index.php?page=user.admin.edit&amp;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>.