From 1c32172efb18e8d08ea483e2460813670ebfe1a5 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sat, 30 Sep 2006 18:40:40 +0000 Subject: merge from 3.0 branch till 1451. --- .../protected/pages/Configurations/UrlMapping.page | 41 +++++++++++++++------- 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'demos/quickstart/protected/pages/Configurations/UrlMapping.page') diff --git a/demos/quickstart/protected/pages/Configurations/UrlMapping.page b/demos/quickstart/protected/pages/Configurations/UrlMapping.page index dde6854f..ff6f09c7 100644 --- a/demos/quickstart/protected/pages/Configurations/UrlMapping.page +++ b/demos/quickstart/protected/pages/Configurations/UrlMapping.page @@ -1,6 +1,6 @@ -

URL Mapping (Friendly URLs)

+

URL Mapping (Friendly URLs)

@@ -17,16 +17,25 @@ globally in the application configurati file and before any services.

+
Info: +The TUrlMapping must be configured before the +Request module resolves the request. +This usually means delcaring the TUrlMapping module before any +<services> tag in the application configuration. +Specifying the mappings in the per directory config.xml is not supported. +
+

The mapping format is as follows. - +

The ServiceParameter and ServiceID - (the default ID is 'page') set the service parameter and service ID respectively. + (the default ID is 'page') set the service parameter and service ID, respectively, of + the Request module. The service parameter for the TPageService 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. @@ -42,15 +51,15 @@ and a right brace '}'. The pattens for each parameter can be set using Parametersattribute collection. For example, -

-The example is equivalent, using regular expression only, to +The example is equivalent to the following regular expression (it uses the "named group" feature in regular expressions available in PHP): - + \d{4})/(?P\d{2})/(?P\d+) + /articles\/(?P\d{4})\/(?P\d{2})\/(?P\d+)/u ]]> @@ -59,19 +68,27 @@ In the above example, the pattern contains 3 parameters named "year", "month" and "day". The pattern for these parameters are, respectively, "\d{4}" (4 digits), "\d{2}" (2 digits) and "\d+" (1 or more digits). +Essentially, the Parameters attribute name and values are used + as substrings in replacing the placeholders in the Pattern string +to form a complete regular expression string.

-

For example, an URL "http://example.com/index.php/articles/2006/07/21" will be matched +

Note: If you intended to use the RegularExpression +property you need to escape the slash in regular expressions. +
+ +

Following from the above pattern example, +an URL "http://example.com/index.php/articles/2006/07/21" will be matched and valid. However, "http://example.com/index.php/articles/2006/07/hello" is not valid since the "day" parameter pattern is not satisfied. In the default TUrlMappingPattern class, the pattern is matched against the path property of the URL only. For example, only the -"/index.php/articles/2006/07/21" portion of the URL is considered and the rest -is ignored. +"/index.php/articles/2006/07/21" portion of the URL is considered.

- -

The parameter values are available through the standard Request +

+The mapped request URL is equivalent to index.php?page=ArticleView&year=2006&month=07&day=21. +The request parameter values are available through the standard Request object. For example, $this->Request['year'].

-- cgit v1.2.3