I will base the description on one of the basic integrators – contact integrator (com_contact_bot), because of its simplicity.
In general, the aim of the integrator is to check what link has been assigned in the menu and return a relevant item tree.
In case of this example the component can be published in two ways:
- as a contacts category – in such case the following link type is being assigned to menu:
index.php?option=com_contact&view=category&catid=5
- as a contact item - in such case the following link type is being assigned to menu:
index.php?option=com_contact&view=contact&id=1
In the beginning, you should check the link parameters (view parameter for the above links) and depending on the outcome return the relevant item tree (for a category) or return nothing (for a contact item).
The situation is different for content integrator. If the link is relevant to a section, you should return a tree consisting of categories and content items. If the link is relevant to a category, you should return content items only. If it is relevant to a content item, you should return nothing.
An integrator is a standard Joomla! plugin. It differs from others by:
- it should install itself in com_sefservicemap folder;
- depending on the name of the component it should be named [component name]_bot. This regards also the filenames: [component name]_bot.php and [component name]_bot.xml. As you see, for a contact integrator, it should contain at least two files: com_contact_bot.php and com_contact_bot.xml. Contact integrator includes also a picture of the contact item, so the whole contact integrator should consist of three files.
- plugin should contain function named [component name]_bot. Example:
function com_contact_bot ( $level, $link, $Itemid, $params ) {
.....
AddExtMenuitem ($element);
.....
}
where:
$level – this is the level on the map tree. Level 0 means root. Each subsequent $level number will be larger by 1.
$link – this is the link connected in the menu to a specific item.
$Itemid – this is a menu id;
$params – this is JParameter object along with parameters signed to the integrator (returned on the basis of XML file definition of integrator);
There are two additional functions:
- AddExtMenuitem ( $element); - adds an element to the map;
- smGetParam ( $link, $what, $default ); - gets parameters from the link;
function smGetParamIN:
smGetParam ( $link, $what, $default );
is a counterpart of JRequest.
$what – this is the parameter we seek;
$default – default value returned when the value of parameter is not;
OUT:
$value
function AddExtMenuitemIN:
AddExtMenuitem ( $element );
$element = stdClass();
$element->name – name of the item (in this case contact name);
$element->link – contact link - 'index.php.....Itemid='.$Itemid The component will automatically change links to SEF when it is required;
$element->level – indicates the level on which the item should be listed;
$element->lastmod – indicates the last modification date of an item;
$element->image – picture which should be shown by a given item;
$element->icon_path - '/plugins/com_sefservicemap/' by default. Path where the picture is.
$element->priority and $element->changefreq – data returned to XML map consistent with http://sitemaps.org specifications
OUT:
null
Requested elements are name and link. If possible, you should return lastmod parameter – it will enable the map detect, whether given item has been modified or not and based on the outcome, whether it should be addend to the pinging queue;
This is a full list of contact integrator contents:
This is Manifest XML along with indication of integrator’s elements:
<?php
/* Function return contact list for $id category */
function Contact_items ($level, $id,$Itemid,$params) {
/* get integrator parameters */
$priority=$params->get( 'priority', '' ) ;
$changefreq=$params->get( 'changefreq', '' );
$show_item_icons=intval($params->get( 'show_item_icons', '1' )) ;
$db = JFactory::getDBO();
$user = &JFactory::getUser();
$aid = (int) $user->get('aid', 0);
/* query to database */
if ($id) $cat_sel = " and a.catid='".$id."'"; else $cat_sel='';
$db->setQuery("SELECT a.*, b.alias as 'catalias' FROM #__contact_details AS a LEFT JOIN #__categories AS b ON a.catid = b.id
where a.published >='1'".$cat_sel." and a.access<='$aid' order by a.ordering");
$items=$db->loadObjectList();
/* one level down */
$lev=$level+1;
if (count($items!=0)) {
foreach ($items as $item) {
/* set element parameters */
$link="index.php?option=com_contact&view=contact&id=".$item->id.":"
.$item->alias."&catid=".$item->catid.";".$item->catalias."&Itemid=".$Itemid;
$element->name = $item->name;
$element->link = $link;
$element->level = $lev;
$element->priority = $priority;
$element->changefreq= $changefreq;
if ($show_item_icons) $element->image = 'contact_people.gif'; else $element->image='none';
$element->icon_path='/plugins/com_sefservicemap/';
/* add element to site map */
AddExtMenuItem ($element);
}
}
}
/* Start */
function com_contact_bot ($level,$link,$Itemid,$params) {
$catid = smGetParam($link,'catid',0);
$view = smGetParam($link,'view','');
if ($view=='category') Contact_items ($level,$catid,$Itemid,$params);
}
?>