1.4. Page structure and CMS integration

MWT adopts a modular approach to build up pages. This approach has proven to be particularly successfull for the mobile web: the code to be rendered is divided into small blocks, each block is a widget, providing a specific functionality. By reusing widgets, pages content can be easily controlled and pages can be kept smaller.

In MWT a page is a simple structure that is defined by the list of its building blocks: the widgets. A widget is a php script, and it's what actually contains the code to be rendered. The script normally contains two sections:

Besides specifying the list of internal widgets a page can provide the configuration for each internal widget. Therefore each widget can have a configuration that is page-specific, and this enables you to reuse a widget in different pages with a page-dependant behaviour.

A part from being a container for the widgets, a page is also the interface between the CMS and the widgets. MWT provides a CMS integration layer allowing easily integration of the framework in any CMS. The integration layer is responsible for instantiating pages depending on the requested URL. When instantiating a page object the CMS layer passes to it a set of parameters that are needed to identify the content to be diplayed, the page object itself is responsible to make these parameters available to its inner widgets.

The dispatching process is illustrated in the diagram below where the requested URL maps a Wordpress post in MWT:

The Mobile site map term is used to classify all the pages making up the mobile version of a website.

In the case of MWT as a Wordpress plugin, there can be three different kind of pages in the Mobile site map:

As already described, for each content type in the CMS there is a corrisponding content display page.

The page receives a set of parameters that uniquely identifies the content to display from the CMS integration layer, and forwards the parameters to its inner widgets.

The table below displays information about content display pages for Wordpress:

ContentPage nameParametersURL-mapping
home  */mobile/start
postsingle_postp (post ID)/archives/postID
pagesingle_pagepage_uri (page path)/pages/page_path
categorycategorycategory (category ID)/archives/category/catID
page listpage_list /pages
comment listcomment_listpost_id (post ID)/archives/comments/postID

Values in the URL-mapping column are relative URLs (part of the URL after the device ID, see section URL rewriting).

*Home is the only URL that doesn't contain the device ID, if the URL of Wordpress blog is http://127.0.0.1/mwt, the complete URL for the home of the mobile version is http://127.0.0.1/mwt/index.php/mobile/start

Widgets are reusable building blocks that make up pages. A widget is normally just a code snippet providing a specific functionality or displaying content from the CMS.

Every page defines an ordered list of widgets, whenthe pages object is created the inner widgets are rendered consecutively. The widget file can contain a section that defines the configuration options for the widget. To enhance reusability, widget behaviour can be page-dependant, as widgets can be configured differently from page to page.

Widget configuration is a XML fragment placed at the bottom of the widget file. The XML syntax is the following:

It's possible define as many configuration parameters as needed. Each parameter has a name, a type, a default value, a list of possible values and a description. The only obligatory field is the parameter name, all the fields will default to blank values.

Widgets can be placed in pages and configured in the MWT Editor. The configuration parameter type defines the form element used to set the parameter value in the editor. Valid types are:

Of course it only makes sense to provide a comma-separated list of possible values if the parameter type is select or radio.