1.6. MWT APIs

Whether you decide to write widgets using taglibs (see Chapter 2) or PHP you have access to a set of APIs. MWT APIs have already been classified in paragraph Widget Body, here we we provide a detailed description.

To find out how to access MWT APIs in PHP scripts and taglibs read these paragraphs:

Through this APIs you can retrieve the list of supported device models and brands, get informations about the current device, perform a device switch to render pages for a specific device.

After reading this paragraph you should read the section describing how to link content with the standard A tag

This function can be used to link content. The returned URL is in the form of MWT URLs (see paragraph URL rewriting) and contains the current device ID. The leading part of parameter pathToContent identifies the type of content while its trailing part maps the content to link. Possibile cases are summarized in the following table:

pathToContentgenerated URL
post/postIDhttp://127.0.0.1/mwt/index.php/mobile/ua_id/archives/postID
comment/postIDhttp://127.0.0.1/mwt/index.php/mobile/ua_id/archives/comments/postID
page/pagepathhttp://127.0.0.1/mwt/index.php/mobile/ua_id/pages/pagepath
category/catIDhttp://127.0.0.1/mwt/index.php/mobile/ua_id/archives/category/catID
userpage/mypagehttp://127.0.0.1/mwt/index.php/mobile/ua_id/generic/mypage

This function lets you retrieve widget configuration (see Widgets configuration). Parameter paraName is the name of the configuration parameter whose value you want to retrieve.

string input(paraName,  
 defaultValue=0); 
string  paraName;
string  defaultValue=0;

This function lets you retrieve the value of input parameters (see Page structure and CMS integration). Parameter paraName is the name of the input parameter whose value you want to retrieve. Sometimes you can place widgets in pages that don't provide them the expected input parameters, in this cases you can call specify a value for the defaultValue parameter when calling input: if paraName it is not found, input returns defaultValue.