I had 2 problems with implementing this hack, most likely because templates have changed slightly ( I am on version
1.3.4 and could not find "<!--if (isset(CAT_ALBUMS)){-->" in my template). I am using
Mac_ox_x scheme and I wanted categories in 2 columns.
The problems were:a) if there are only 2 categories: sometimes they are displayed in one column (one underneath another) instaed of in one row (one side by side)
b) if there is an uneven number of categories then the last cell is an ugly, grey box.
Solutions:I think the best thing to do here would be to list all changes I have made. I would, however, like to emphasise that 99.999% of those changes have been thought of and generously contiributed here by ve.ru (see previous posts) who takes full credit for this useful hack. I will mostly repeat what was already posted above, but I have consolidated all the changes, which was very easy, at least in this particular template, because all sections are all next to each other. For those of You who have those sections all over the place, the sections changed were "BEGIN header","BEGIN catrow_noalb", "BEGIN catrow" and "BEGIN footer" and one new section: BEGIN "catrow_blank".
The end result can be seen here =>
MadPole & Co Visual Arts Gallery1. Template sectionsreplace the forementioned sections with this:
<!-- BEGIN header -->
<tr>
<td class="tableh1" width="40%"><b>{CATEGORY}</b></td>
<td class="tableh1" width="5%" align="center"><b>{ALBUMS}</b></td>
<td class="tableh1" width="5%" align="center"><b>{PICTURES}</b></td>
<td class="tableh1" width="40%"><b>{CATEGORY}</b></td>
<td class="tableh1" width="5%" align="center"><b>{ALBUMS}</b></td>
<td class="tableh1" width="5%" align="center"><b>{PICTURES}</b></td>
</tr>
<!-- END header -->
<!-- BEGIN catrow_noalb -->
<tr>
<td class="tableh2" colspan="6"><table border="0"><tr><td>{CAT_THUMB} {DEBUG}</td><td><span class="catlink"><b>{CAT_TITLE}</b></span>{CAT_DESC}</td></tr></table></td>
</tr>
<!-- END catrow_noalb -->
<!-- BEGIN catrow -->
<td class="tableb"><table border="0"><tr><td>{CAT_THUMB}</td><td><span class="catlink"><b>{CAT_TITLE}</b></span>{CAT_DESC}</td></tr></table></td>
<td class="tableb" align="center">{ALB_COUNT} {DEBUG}</td>
<td class="tableb" align="center">{PIC_COUNT}</td>
<!-- END catrow -->
<!-- BEGIN catrow_blank -->
<td class="tableb" align="center"></td>
<td class="tableb" align="center">{DEBUG}</td>
<td class="tableb" align="center"></td>
<!-- END catrow_blank -->
<!-- BEGIN footer -->
<tr>
<td colspan="6" class="tableh1" align="center"><span class="statlink"><b>{STATISTICS}</b></span></td>
</tr>
<!-- END footer -->
2. theme_display_cat_list functionReplace the whole function with the following (but check first of all that your function looks similar, particularly if you are trying it on different set of templates)
function theme_display_cat_list($breadcrumb, &$cat_data, $statistics)
{
global $template_cat_list, $lang_cat_list;
starttable('100%');
if (count($cat_data) > 0) {
$template = template_extract_block($template_cat_list, 'header');
$params = array('{CATEGORY}' => $lang_cat_list['category'],
'{ALBUMS}' => $lang_cat_list['albums'],
'{PICTURES}' => $lang_cat_list['pictures'],
);
echo template_eval($template, $params);
}
$template_noabl = template_extract_block($template_cat_list, 'catrow_noalb');
$template = template_extract_block($template_cat_list, 'catrow');
$template_blank = template_extract_block($template_cat_list, 'catrow_blank');
$count=0;
$columnCount=2;
echo "<tr>";
foreach($cat_data as $category) {
$count++;
if (count($category) == 3) {
if ($count%$columnCount==0) {
$params = array('{DEBUG}' => "");
echo template_eval($template_blank, $params);
}
$params = array('{CAT_TITLE}' => $category[0],
'{CAT_THUMB}' => $category['cat_thumb'],
'{CAT_DESC}' => $category[1],
'{DEBUG}' => ""
);
$count=0;
echo template_eval($template_noabl, $params);
} else {
$params = array('{CAT_TITLE}' => $category[0],
'{CAT_THUMB}' => $category['cat_thumb'],
'{CAT_DESC}' => $category[1],
'{CAT_ALBUMS}' => $category['cat_albums'],
'{ALB_COUNT}' => $category[2],
'{PIC_COUNT}' => $category[3],
'{DEBUG}' => ""
);
echo template_eval($template, $params);
}
if ($count%$columnCount==0) {
echo "</tr> <tr>";
}
}
echo "</tr>";
if ($statistics && count($cat_data) > 0) {
$template = template_extract_block($template_cat_list, 'footer');
$params = array('{STATISTICS}' => $statistics);
echo template_eval($template, $params);
}
endtable();
if (count($cat_data) > 0)
echo template_extract_block($template_cat_list, 'spacer');
}
Explanations:
Sections{DEBUG} variable has been added purely for debugging purposes
- BEGIN header: 3 cells duplicated for the 2nd column and their all widths cut by half
- BEGIN catrow: the wrapping <tr> </tr> tags deleted
- BEGIN catrow_noalb: columnspan changed from 3 to 6
- BEGIN footer: columnspan changed from 3 to 6
- BEGIN catrow_blank: new section, displays blank cell when there is an uneven number of categories
theme_display_cat_list function
- $count is reset to 0 every time we start a new category. This is only a cosmetic change which makes degugging easier
- $count++; is at the begining of the loop. This is to prevent $count%$columnCount==0 when $count is 0 (and therefore 2 first categories appearing underneath each other)
- and finally: we now output blank template/cell when we have an uneven number of categories. The condition
$count%$columnCount==0 below
if (count($category) == 3) is misleading and horrible but works because uneven
$count++; already bumped
$count to an even number. I am sure this could be and SHOULD BE replaced by something which makes more sense hehehehe...
[/list]
I used
{DEBUG} variable to output values of $count and other variables because I am lazy and don't know php and could not get the damn thing to work... only when I saw the values of counters I realized what was wrong!

I also attached the whole template as promised earlier.....