'Use a nested list instead of using sidebar headers formatting for top-level categories'); var $default_context = LP_CONTEXT_ALL; var $description = 'Display a list of active categories'; var $active = true; var $hooks = array('sidebar'); var $nested = false; function CategoriesList(&$frontend, $args, $dummy_run=false) { $this->LightPressPlugin($frontend, $args, $dummy_run); } function run($hook, &$hook_data) { $tpl =& $this->_frontend->tpl; $config_messages =& $this->_frontend->messages; $tpl->setVar('plugin_categorieslist_header', $config_messages['categories_header']); $tpl->setFile('plugin_categorieslist', 'plugins/categories_list' . ($this->nested ? '_nested' : '') . '.xml'); $tpl->setBlock('plugin_categorieslist', 'plugin_categorieslist_catgroup', 'PLUGIN_CATEGORIESLIST_CATGROUP'); $tpl->setBlock('plugin_categorieslist_catgroup', 'plugin_categorieslist_category', 'PLUGIN_CATEGORIESLIST_CATEGORY'); $catgroup = null; $categories =& $this->_frontend->getCategories(); if (count($categories) == 0) return $this->hide(); foreach ($categories as $cat_id => $cat) { $append = true; if (!$this->nested && is_null($cat['catgroup'])) $cat['catgroup'] = $config_messages['categories_header']; if (!empty($cat['num_child'])) continue; if ($cat['catgroup'] != $catgroup) { if (!is_null($catgroup)) { $tpl->setVar($catgroup_tpl); $tpl->parse('PLUGIN_CATEGORIESLIST_CATGROUP', 'plugin_categorieslist_catgroup', true); } $catgroup_tpl = array( 'plugin_categorieslist_catgroup_name' =>$cat['catgroup'], 'plugin_categorieslist_catgroup_nicename' =>$cat['catgroup_nicename'], 'plugin_categorieslist_catgroup_permalink' =>$cat['catgroup_permalink']); $catgroup_id = $cat['catgroup_id']; if ($this->nested && isset($categories[$catgroup_id])) $catgroup_tpl['plugin_categorieslist_catgroup_numposts'] = $categories[$catgroup_id]['numposts']; else $catgroup_tpl['plugin_categorieslist_catgroup_numposts'] = ''; $catgroup = $cat['catgroup']; $append = false; } $tpl->setVar(array( 'plugin_categorieslist_category_permalink'=>$cat['category_permalink'], 'plugin_categorieslist_category_nicename'=>$cat['category_nicename'], 'plugin_categorieslist_category_name'=>$cat['cat_name'], 'plugin_categorieslist_category_description'=>$cat['category_description'], 'plugin_categorieslist_category_numposts'=>$cat['numposts'], )); $tpl->parse( (is_null($catgroup) ? 'PLUGIN_CATEGORIESLIST_CATGROUP' : 'PLUGIN_CATEGORIESLIST_CATEGORY'), 'plugin_categorieslist_category', $append); } if (!is_null($catgroup)) { $tpl->setVar($catgroup_tpl); $tpl->parse('PLUGIN_CATEGORIESLIST_CATGROUP', 'plugin_categorieslist_catgroup', true); } $tpl->parse('PLUGIN_CATEGORIESLIST', 'plugin_categorieslist', true); } } ?>