History of CreatingServices

Version 1


a developers guide to generating services

Created by: xing, Last modification: 15 Feb 2006 (21:44 UTC) by xing
a brief outline of what a service is and what it does, can be found on LibertyServices

Turning a package into a service

register the package as service

to turn any package into a service, you need to modify your <pkg>/bit_setup_inc.php file and declare your package into a service. this can be done by modifying the way the package is registered:

->registerPackage'pigeonholes'dirname__FILE__).'/'TRUELIBERTY_SERVICE_CATEGORIZATION );

explaining the parameters of registerPackage:
  1. name of the package
  2. package path
  3. specify if the package can be activated
  4. specify what type of service the package belongs to

the service type needs to be defined as a constant in liberty/LibertySystem.php - this is also the place where you can check what types of services we already have and if your's fits into one of the existing ones, please use one of those.

register the service

this is the cruicial bit. we register the service and when to display what and where.

if( $gBitSystem->isPackageActive'pigeonholes' ) ) {
'content_display_function' => 'pigeonholes_content_display',
'content_preview_function' => 'pigeonholes_content_preview',
'content_edit_function' => 'pigeonholes_content_input',
'content_store_function' => 'pigeonholes_content_store',
'content_expunge_function' => 'pigeonholes_content_expunge',
'content_edit_tab_tpl' => 'bitpackage:pigeonholes/pigeonholes_input_inc.tpl',
'content_view_tpl' => 'bitpackage:pigeonholes/display_members.tpl',
'content_nav_tpl' => 'bitpackage:pigeonholes/display_paths.tpl',
    ) );

you can see that the pigeonholes package first checks to see if it's active, if so, it adds the service specifications.

Service Options

Sql Extensions

allows the extension of existing SQL while getList() is called. table aliases are kept constant throughout so you can easily join pertinent data to the existing SQL when getList() is called from any package.

function protector_content_list() {
$groups array_keys($gBitUser->mGroups);
$ret = array(
'join_sql' => " LEFT JOIN `".BIT_DB_PREFIX."liberty_content_group_map` lcgm ON ( lc.`content_id`=lcgm.`content_id` ) LEFT OUTER JOIN `".BIT_DB_PREFIX."users_groups_map` ugm ON ( ugm.`group_id`=lcgm.`group_id` ) ",
'where_sql' => " AND (lcgm.`content_id` IS NULL OR lcgm.`group_id` IN("implode(','array_fill(0count($groups), '?')) ." ) OR ugm.`user_id`=?) ",
'bind_vars' => array( $gBitUser->mUserId ),
$ret['bind_vars'] = array_merge$groups$ret['bind_vars'] );

You can also insert some select_sql as well, to limit the selection critieria.

This is basically the same as content_list_sql_function but it's called during the load() process. the output should be virtually the same.


This function is called during the displaying of the content, i.e. while the page is being loaded. this means, you can add more sophisticated queries and checks in here, if there is no possibility to do this with the SQL functions above.

This function is called when a page is being editied and a user hits preview. it's mostly there for you to make any selections the user has made persistent during the preview phase.

When a user wants to edit content, this function is called. it allows you to generate data for any templates you need to fill in the edit page (more below).

Here you can store the content data in your serice tables.

Make sure the data from your tables is removed when a user removes the content it belongs to.


This template is displayed as a seperate tab when a user is editing content. this is useful for services that might contain several lines of code and want to have their own section when a user edits a page. This template is only available when the user is editing data.

This template is displayed during the edit process and is particularly useful when you have a single dropdown to display, since it's displayed below the textarea a user uses to edit the content. This template is only available when the user is editing data.

This template is appended to the bottom of the page, like a list of pages in the same category. This is only visible when the full content is loaded i.e.: when an article is being read but not just viewed on the front page.

You can use this to insert a narrow template at the top of a page. this can be useful to display the path to an object or the status of a page. This is only visible when the full content is loaded i.e.: when an article is being read but not just viewed on the front page.

insert an icon in the list of existing icons in the top right on a page. This will enable you to get your users to link to a template in your own package and deal with certain needs that way.

insert a small template into the top of the
part of the content. this template will be visible in listings such as the articles front page as well.
Page History
28 Aug 2006 (17:22 UTC)
adds image
Current • Source
View • Compare • Difference • Source
View • Compare • Difference • Source
View • Compare • Difference • Source