diff options
Diffstat (limited to 'demos')
-rw-r--r-- | demos/blog/protected/application.php | 12 | ||||
-rw-r--r-- | demos/blog/protected/application.xml | 10 | ||||
-rw-r--r-- | demos/personal/protected/application.xml | 6 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/Configurations/UrlMapping.page | 42 |
4 files changed, 56 insertions, 14 deletions
diff --git a/demos/blog/protected/application.php b/demos/blog/protected/application.php index c6f26c7e..d7d7c97b 100644 --- a/demos/blog/protected/application.php +++ b/demos/blog/protected/application.php @@ -75,12 +75,12 @@ return array( 'class' => 'Application.Common.BlogDataModule', ), ), - ), - ), - 'pages' => array( - 'properties' => array( - 'MasterClass' => 'Application.Layouts.MainLayout', - 'Theme' => 'Basic', + 'pages' => array( + 'properties' => array( + 'MasterClass' => 'Application.Layouts.MainLayout', + 'Theme' => 'Basic', + ), + ), ), ), );
\ No newline at end of file diff --git a/demos/blog/protected/application.xml b/demos/blog/protected/application.xml index 1ab6a9c0..d28b2dd7 100644 --- a/demos/blog/protected/application.xml +++ b/demos/blog/protected/application.xml @@ -6,10 +6,10 @@ </paths>
<!-- modules configured and loaded for all services -->
<modules>
-
- <module id="request" class="THttpRequest" UrlFormat="Path" UrlManager="friendly-url" />
-
- <!--<module id="cache" class="System.Caching.TSqliteCache" />-->
+ <!-- Remove this comment mark to enable PATH url format
+ <module id="request" class="THttpRequest" UrlFormat="Path" />
+ -->
+ <module id="cache" class="System.Caching.TSqliteCache" />
<module class="Application.Common.BlogErrorHandler" />
<module id="log" class="System.Util.TLogRouter">
<route class="TFileLogRoute" Categories="BlogApplication" />
@@ -17,7 +17,7 @@ <module class="System.Util.TParameterModule" ParameterFile="Application.Data.Settings" />
<!-- use TUrlMapping to map URL patterns to particular requests -->
- <module id="friendly-url" class="System.Web.TUrlMapping" EnableCustomUrl="true">
+ <module id="friendly-url" class="System.Web.TUrlMapping">
<url ServiceParameter="Posts.ViewPost" pattern="post/{id}/?" parameters.id="\d+" />
<url ServiceParameter="Posts.ListPost" pattern="archive/{time}/?" parameters.time="\d{6}" />
<url ServiceParameter="Posts.ListPost" pattern="category/{cat}/?" parameters.cat="\d+" />
diff --git a/demos/personal/protected/application.xml b/demos/personal/protected/application.xml index e9115f29..b67df94a 100644 --- a/demos/personal/protected/application.xml +++ b/demos/personal/protected/application.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?>
-<application id="personal" mode="Debug">
+<application id="personal" mode="Normal">
<paths>
<using namespace="Application.Common.*" />
</paths>
@@ -34,6 +34,6 @@ </service>
</services>
<parameters>
- <parameter id="siteName" value="My Personal Site" />
+ <parameter id="siteName" value="My Personal Site" />
</parameters>
-</application>
+</application>
\ No newline at end of file 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>.
|