Handling URLs

Handle URLs more effectively

In C1 CMS, to handle a CMS Page URL, especially dynamically generated, you normally use the following model:

~/Page({GUID})

where {GUID} is the ID of the needed page.

On the front-end, it will be resolved to something like:

http://localhost/MyPage

You can use query strings, the PathInfo and the combination thereof with ~/Page({GUID}) and they will be resolved like this:

Dynamic PathResolved Path
~/Page({GUID})?QueryString=Value/MyPage?QueryString=Value
~/Page({GUID})?QueryString1=Value1&QueryString2=Value2/MyPage?QueryString1=Value1&QueryString2=Value2
~/Page({GUID})/PathInfo/MyPage/PathInfo
~/Page({GUID})/PathInfo?QueryString=Value/MyPage/PathInfo?QueryString=Value

For example:

Query String

<!-- this is sample XSLT - referencing two dynamic values -->
<a href="~/Page({$somePageGuid})?c={@someProductId}" />

The link will be resolved to something like: http://localhost/Products?c={id}

PathInfo

<!-- this is sample XSLT - referencing two dynamic values -->
<a href="~/Page({$somePageGuid})/{@someProductId}" />

The link will be resolved to something like: http://localhost/Products/{id}

<!-- register the PathInfo usage -->
<f:function name="Composite.Web.Request.RegisterPathInfoUsage" xmlns:f="http://www.composite.net/ns/function/1.0"  /> 

Please note that pages that you request with extra path info must register that this is actually OK - that this is not a 404 request. In the above example you can see how you register the PathInfo usage with the Composite.Web.Request.RegisterPathInfoUsage function. If you do not do this, the extra path is treated as "unknown" and the URL results in a HTTP 404 File Not Found.

To query the PathInfo values use one of these CMS Functions:

  • Composite.Web.Request.PathInfo
  • Composite.Web.Request.PathInfoGuid
  • Composite.Web.Request.PathInfoInt

To read about these functions, generate their documentation in the CMS Administrative Console:

  1. In the Functions perspective, expand All Functions > Composite > Web.
  2. Select Request.
  3. Click Generate Documentation on the toolbar
  4. Locate these function and read their descriptions.

For information about the C1 CMS API for PathInfo, please read "API to work with PathInfo".