Plugins pour afficher les catégories dans Joom map. Adaptation du plugins par défaut
Vu sur le forum de phoca et adapté à la version 2.5.8 et rajout de la prise en compte correcte des menus.
//TODO : Modification de la sql pour cacher les entrées non publique ( non visible même si on clique dessus si c'est bien configuré )
phoca.plugin.php à placer dans /administrator/components/com_joomap/plugins
<?php
$phocamap = new Joomap_PhocaGallery;
JoomapPlugins::addPlugin( $phocamap );
class Joomap_PhocaGallery {
function isOfType( &$joomla, &$parent ) {
if( strpos($parent->link, 'option=com_phocagallery') ) {
return true;}
return false;
}
function &getTree( &$joomap, &$parent ) {
$database =& JFactory::getDBO();
$list = array();
$database->setQuery("select id, title, parent_id from #__phocagallery_categories order by ordering");
$categories = $database->loadObjectList();
$menu = &JSite::getMenu();
$itemscat= $menu->getItems('link', 'index.php?option=com_phocagallery&view=categories');
foreach($categories as $category) {
$node = new stdclass;
$node->id = $category->id;
$node->name = $category->title;
$node->tree = array();
$node->pid = $category->parent_id;
$node->type = 'component';
if(isset($itemscat[0])){
$node->link = 'index.php?option=com_phocagallery&view=category&id='. $category->id .'&Itemid='.$itemscat[0]->id;
} else {
$node->link = 'index.php?option=com_phocagallery&view=category&id='. $category->id .'&Itemid=0';
}
$list[$category->id] = $node;
}
foreach( $list as $id => $category ) { // rendre les enfants aux parents
if( $category->pid > 0 && isset($list[$category->pid]) ) {
$list[ $category->pid ]->tree[$id] = &$list[$id];
}
}
foreach( $list as $id => $category ) { // enlever les enfants sans parents
if( $category->pid > 0 ) {
unset( $list[$id] );
}
}
return $list;
}
}
?>