forum.coppermine-gallery.net
Support => cpg1.5.x Support => cpg1.5 themes (visuals) => Topic started by: xhpohanka on May 04, 2011, 07:00:46 pm
-
Hello,
I know there was a similar question some days ago, also there exists a plugin that hides empty categories but it affectes also 'parent' categories which contains no albums but another nonempty ones. How can I please let the parent categories (but with no albums) still visible?
regards
Jan
http://galerie.honza-centrum.cz/galerie/index.html (http://galerie.honza-centrum.cz/galerie/index.html)
-
That's no trivial task according to how the catlist is currently built. You'd need to check for every category with all their sub-categories if they contain albums/files the user is able to access. I currently don't see a straight-forward solution. Maybe you should hire a freelancer.
-
I think I should be able to implement it, just please give me a short advice where to start, please...
-
I don't know where the best point to start is. The plugin (http://forum.coppermine-gallery.net/index.php/topic,69444.0.html) modifies the function theme_display_cat_list. Instead of commenting out
$params = array(
'{CAT_TITLE}' => $category[0],
'{CAT_THUMB}' => $category['cat_thumb'],
'{CAT_DESC}' => $category[1],
);
echo template_eval($template_noalb, $params);
in general you could add a check if the category is really 'empty'.
Maybe it's easier to add some checks at an earlier stage, but I haven't checked that.
If you find a solution I suggest to share it in this or in the plugin thread.
-
Maybe it's easier to add some checks at an earlier stage, but I haven't checked that.
If you find a solution I suggest to share it in this or in the plugin thread.
If someone is interested I have done small modifications in index.php and theme.inc.php to achieve proposed behavior.
index.php: add information about subcat_alb_count
function get_subcat_data(&$cat_data)
...
while ( ($row = mysql_fetch_assoc($result)) ) {
if ($row['cid'] == 1) {
if (!empty($user_galleries)) {
$categories[$row['cid']] = $user_galleries;
}
continue;
}
$categories[$row['cid']]['details'] = array(
'name' => $row['name'],
'description' => $row['description'],
'thumb' => $row['thumb'],
'level' => $row['depth'],
'alb_count' => 0,
'subcat_alb_count' => 0,
);
} // while
mysql_free_result($result);
// collect album counts for categories that are visible
$sql = "SELECT category, COUNT(*) AS num, c.parent
FROM {$CONFIG['TABLE_ALBUMS']} AS a
INNER JOIN {$CONFIG['TABLE_CATEGORIES']} AS c ON cid = category
WHERE depth BETWEEN $CURRENT_CAT_DEPTH + 1 AND $CURRENT_CAT_DEPTH + {$CONFIG['subcat_level']}";
// if we are in a category, restrict info to children
if ($rgt) {
$sql .= "\nAND lft BETWEEN $lft AND $rgt";
}
if (!$CONFIG['show_private'] && $FORBIDDEN_SET_DATA) {
$sql .= ' AND a.aid NOT IN (' . implode(', ', $FORBIDDEN_SET_DATA) . ')';
}
// we don't care about the order
$sql .= "\nGROUP BY category ORDER BY NULL";
$result = cpg_db_query($sql);
while ( ($row = mysql_fetch_assoc($result)) ) {
$categories[$row['category']]['details']['alb_count'] = $row['num'];
if ($row['parent'] != 0) {
$categories[$row['parent']]['details']['subcat_alb_count'] = $row['num'];
}
}
...
if ($pic_count == 0 && $album_count == 0) {
$user_thumb = str_repeat($indent, $level-1);
$cat_data[] = array($link, $cat['details']['description'], 'cat_thumb' => $user_thumb, 'subcat_alb_count' => $cat['details']['subcat_alb_count']);
} else {
...
theme.inc.php:
...
if (!isset($category['cat_thumb'])) { $category['cat_thumb'] = ''; }
if (count($category) == 4) {
if ($category['subcat_alb_count'] > 0) {
$params = array(
'{CAT_TITLE}' => $category[0],
'{CAT_THUMB}' => $category['cat_thumb'],
'{CAT_DESC}' => $category[1],
);
echo template_eval($template_noalb, $params);
}
}
...
regards
Jan
-
Can you please post your modifications like this:
In file xyz.php, find
foo
and replace with
bar
Thanks.