Site urls

Site urls represent the public urls that an application managed with Webpagebytes CMS will publish to be accessible through HTTP requests.

The Webpagebytes CMS admin web interface allows to create, edit or delete the urls of the site under the Site urls menu section.
A site url has the following attributes

Attribute name Attribute description
Site uri Site uri is the url part for the current serlvet context
Live flag If the value is 'NO' then the HTTP request matched against the current site url will return 404. If the value is 'Yes' then the response will be delivered according to 'Resource Type' value.
Http operation The HTTP verb that is assigned to current site url. Possible values are GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH.
Resource type Specifies how the HTTP response will be generated (see Create new site url below).
Resource External Key Specifies what resource will be used to generate the HTTP response (see Create new site url below).
Uri controller Custom server side code to generate the HTTP response (see Create new site url below).

Create new site url

If the application managed with Webpagebytes CMS needs to respond to a HTTP request on a specific url then a site url needs to be created for this. The CMS can return content as a response of an url request in three ways:

Site url resource type Screenshot from administration interface

Link a site url with a site page.

For example a site url /home will be linked with an html page defined under site pages named home-page.

In this case the Resource type value is Site page .

Link a site url with a site file.

For example a site url /js/jquery-1.11.min.js will be linked with an a file uploaded in Files section that contains the jquery-1.11.min.js java script code.

In this case the Resource type value is File .

Implement a server side controller

The server side controller will execute custom code to produce the response content. For example the controller can fetch xls-fo content from a site page and with Apache FOP to generate a PDF file.

In this case the Resource type value is Url controller .

Dynamic urls

Sometimes a web application has a lot of resources that needs to be published on a common url.
There are two ways to specify such dynamic urls, one way is via the query parameters (something like http://example.com/transaction?id=12345) and the other way is via the hierarchical part of the url (something like http://example.com/transaction/12345).

This documentation will cover the dynamic parameters in the url hierarchical part.

We take the example of the Demo application where the payment report can display a graph for the last day, last 7 days and last 30 days, the urls are specified below:
  • http://www.webpagebytes.com/demo/report-transactions-1
  • http://www.webpagebytes.com/demo/report-transactions-7
  • http://www.webpagebytes.com/demo/report-transactions-30
The French language will have the following urls
  • http://www.webpagebytes.com/demo/fr/report-transactions-1
  • http://www.webpagebytes.com/demo/fr/report-transactions-7
  • http://www.webpagebytes.com/demo/fr/report-transactions-30
Webpagebytes CMS allows to define site urls like: /report-transactions-{interval} and /{language}/report-transactions-{interval}

As can be seen the dynamic parts are represented by the parameters specified in curly brackets like {language} and {interval} which will be matched on runtime with the actual parameter values.
A site url can have many dynamic parameters defined, there are no restrictions, however in practice there should not be a need for more than two-three dynamic parameters per each site url.

Webpagebytes CMS matches the request urls against the site urls in the following order:

Some examples below
Site uri HTTP request uri Notes
/{language}/report-transactions-{interval}

/report-transactions-{interval}
/report-transactions-7 Request will be matched against /report-transactions-{interval}

The {interval} parameter will get the value "7"
/{language}/report-transactions-{interval}

/report-transactions-{interval}
/en/report-transactions-30 Request will be matched against /{language}/report-transactions-{interval}

The {interval} parameter will get the value "30" and {language} parameter will get the value "en"

If the request cannot be matched with any site url then the HTTP status code returned will be 404.

Site urls and static files

Webpagebytes CMS allows to upload static files organised under a tree like folder structure, similar with the file system concept (see Site files for more info). For example a web application has to use a third party library that contains javascript, css and image files, organised under a folder. Since these files are third party ones, the web application will not modify them, so the best way is to import them as a folder under Site files section.

A site url can serve the files under a site file folder by using the uri /folder_name/{**}
The keyword {**} means that all the files and sub folders under folder_name (it goes recursive) are available via HTTP GET requests.

Webpagebytes CMS Demo application is using Font Awesome library and imported the library files under a 'fa' folder.
In order to serve the library files it defined a site url as /fa/{**}
This means that all files under /fa/ folder will be available via HTTP GET requests.

Some example of such files are:
/fa/css/font-awesome.min.css
/fa/fonts/FontAwesome.otf

Site urls and localization

Webpagebytes CMS supports localization by keeping the locale information (country and/or language) inside the url address of the HTTP request.

A site url that needs to support localization will have language and/or country dynamic parameters in the hierarchical url part of the address.

Two example of site urls supporting localization are below:
  • /{language}/test
  • /{language}-{country}/test
If the web application needs to support locales like en, gb, fr, de, it, then the first example can be used.
If the web application needs to support locales like en-GB, en-US, fr-CA, then the second example can be used.

Webpagebytes CMS manages the locales supported by the web application under Site Settings section.
For {language} and/or {country} parts of an url to be matched with a supported project language, a site url must define the corresponding customization parameters. These locale parameters must have the 'Overwrite from url' parameter set to 'Yes' and the 'Locale type' to 'Language' or 'Country'.

If the request comes for a language or country not selected in the Site Settings then the request response status code will be 404.

Site url customization parameters

Site url customization parameters are key-value pairs that are specific to each site url and can be used to customize their behavior.

Suppose the web application has a site uri /registration and a POST HTTP request on this url will create an account. On account creation the application will want to send an email to the user.
A url customization parameter can be the site page that contains the email body template so that the application controller can fetch the email html body and send the email.

See WPBModel.URI_PARAMETERS_KEY on how server side controllers can access a site url customization parameter.
See wpbUriParams model key on how a script code (site page or page module) can access a site url customization parameter.