
Originally Posted by
timdwyer42
Hi I'm looking to put my top catagories across the top like on your site. Can you explain how you did this?
Thanks if you can.
Someone else within this thread helped me. I went through my files and if I am not mistaken this is where you modify. includes/classes/categories_ul_generator.php. I am not sure where so I included whole file. You may want to use winmerge to see differences.
PHP Code:
class zen_categories_ul_generator {
var $root_category_id = 0,
$max_level = 6,
$data = array(),
$root_start_string = '',
$root_end_string = '',
$parent_start_string = '',
$parent_end_string = '',
$parent_group_start_string = '<ul%s>',
$parent_group_end_string = '</ul>',
$child_start_string = '<li%s>',
$child_end_string = '</li>',
$spacer_string = '
',
$spacer_multiplier = 1;
var $document_types_list = ' (3) ';// acceptable format example: ' (3, 4, 9, 22, 18) '
function zen_categories_ul_generator($load_from_database = true)
{
global $languages_id, $db;
$this->data = array();
$categories_query = "select c.categories_id, cd.categories_name, c.parent_id
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.categories_id = cd.categories_id
and c.categories_status=1 " .
" and cd.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
" order by c.parent_id, c.sort_order, cd.categories_name";
$categories = $db->Execute($categories_query);
while (!$categories->EOF) {
$this->data[$categories->fields['parent_id']][$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'], 'count' => 0);
$categories->MoveNext();
}
}
function buildBranch($parent_id, $level = 1, $submenu=false) {
if ($parent_id != '0') {
$result = sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level) . '"' : '' );
}
if (($this->data[$parent_id])) {
foreach($this->data[$parent_id] as $category_id => $category) {
$category_link = $category_id;
if (($this->data[$category_id])) {
$result .= sprintf($this->child_start_string, ($submenu==true) ? ' class="submenu"' : '');
} else {
if (($this->data[$category_id]) && ($submenu==false)) {
$result .= sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' : '');
$result .= sprintf($this->child_start_string, ($submenu==true) ? ' class="submenu"' : '');
} else {
$result .= sprintf($this->child_start_string, '');
}
}
if ($level == 0) {
$result .= $this->root_start_string;
}
$result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">';
$result .= $category['name'];
$result .= '</a>';
if ($level == 0) {
$result .= $this->root_end_string;
}
if (($this->data[$category_id])) {
$result .= $this->parent_end_string;
}
if (($this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level > $level+1))) {
$result .= $this->buildBranch($category_id, $level+1, $submenu);
}
$result .= $this->child_end_string;
}
}
if ($level > 0) {
$result .= $this->parent_group_end_string;
}
return $result;
}
function buildTree($submenu=false)
{
return $this->buildBranch($this->root_category_id, '', $submenu);
}
}
?>
Hope this helps. I have 12-13 categories and I am still trying to get spacing to work. I am hoping someone provides response with "how to" with separating each category and modify each in css file. I am not good at generating new css for each category.
Kim
Bookmarks