categories in columns categories in columns
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

categories in columns

Started by ve.ru, October 30, 2004, 06:05:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ve.ru

Hi,

is there a way to have the categories in two or more columns?

thanks,
verena

Joachim Müller

has been asked before, please search the board. If you don't find hits to your particular keywords, re-phrase your search terms.

Joachim

ve.ru

Sorry, but I searched before I wrote my first post and I searched before I wrote this post. All I found was one post with the same question and no answer. Nethertheless, I found a way to realize it. I don't know what the answer to the previos question are but if anyone is interested in how I did this I could post the code.
verena

mid0ri

I'm interested in how you did it. Would you mind sharing the code?

ve.ru

First I have to say that everything is hardcoded in theme.php, I didn't try to make it customizeable. It works with my theme but I don't know if there occure unwanted things with other themes, because I deleted one line of which I am not exactly sure what is it really for, and it looks quite strange if you show more than one category level.

My changes to theme.php:

Search for

$template_cat_list = <<<EOT
<!-- BEGIN header -->


Afterwards is the template of the first row of the table, which includes the category list. Here you have to define how many columns you need. For example, I want the categories 2 columns.

So I just copied the 3 td tags and changed the width. Now it looks so:


<!-- 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 -->


No to to the line
<!-- BEGIN catrow -->
and delete the <tr> and </tr> tag in the following lines

Go to line
<!--if (isset(CAT_ALBUMS)){-->

and delete everything until

<!--};-->

Now look for the function

function theme_display_cat_list($breadcrumb, &$cat_data, $statistics)


Go to the line
foreach($cat_data as $category) {

and isert before (outside the foreach loop):

    $count=0;
    $columnCount=2;
    echo "<tr>";


and now insert after this line (inside the foreach loop):

If ($count%$columnCount==0) {
    echo "</tr><tr>";
}
        $count++;


Go to the line
    if ($statistics && count($cat_data) > 0) {

and insert before:
echo "</tr>";

That's it! now you have to columns with categories.
regards,
Verena

mid0ri

Thanks a lot! Following your instructions I was able to make categories in two columns. Correct me if I'm wrong, but you said:
Quote
Go to line
<!--if (isset(CAT_ALBUMS)){-->
and delete everything until
<!--};-->

If we do that, then in CPG "Classic" theme, we wouldn't be able to see the album thumbnails at all. You said that it works for your theme, would you mind telling me what theme are you using?

midori

ve.ru

Hi,

I'm glad I could help you. I tried to make this modifications to the classic theme and it worked. Did make some other modifications? I wrote this to column example just to show how to do it. I use a theme based on fruity, but I made some more modifications on how to show the categories to make them nearly look like albums. You may have a look at http://www.imageville.eu.tf .
regards,
Verena

mid0ri

Thanks for sharing! I really appreciate it.
Your mod works beautifully on every themes that I've tried, as long as there is no category with empty albums. You're very smart 8)

cwapface

I followed ve.ru's instructions http://forum.coppermine-gallery.net/index.php?topic=11306.0 and got it pretty close, but as you can see something isn't right.  check it out here

http://photos.dylanwiggins.com

here's all the pertinent code, hopefully someone can tell me what i'm overlooking?  thanks

// HTML template for the category list
$template_cat_list = <<<EOT
<!-- BEGIN header -->
       <tr>
               <td class="tableh1" width="20%"><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="20%"><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="20%"><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 -->
               <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}</td>
               <td class="tableb" align="center">{PIC_COUNT}</td>

<!-- END catrow -->



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');
$count=0;
$columnCount=3;
echo "<tr>";

   foreach($cat_data as $category) {



       if (count($category) == 3) {
           $params = array('{CAT_TITLE}' => $category[0],
                   '{CAT_THUMB}' => $category['cat_thumb'],
               '{CAT_DESC}' => $category[1]
               );
           echo template_eval($template_noabl, $params);
       } else {
           $params = array('{CAT_TITLE}' => $category[0],
               '{CAT_DESC}' => $category[1],
                   '{CAT_THUMB}' => $category['cat_thumb'],
               '{CAT_ALBUMS}' => $category['cat_albums'],
               '{ALB_COUNT}' => $category[2],
               '{PIC_COUNT}' => $category[3],
               );
           echo template_eval($template, $params);
       }
If ($count%$columnCount==0) {
echo "</tr><tr>";
}
$count++;
   }
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');
}


Joachim Müller

merged your question with the thread you were refering to.

Joachim

nol33t

Something isn't right because on your theme there still colspan=3 hardcoded in some places

in your theme.php look for something like
Quote
<!-- BEGIN catrow_noalb -->
        <tr>
                <td class="tableh2" colspan="3"><table border="0"><tr><td>{CAT_THUMB}</td><td><span class="catlink"><b>{CAT_TITLE}</b></span>{CAT_DESC}</td></tr></table></td>
        </tr>
<!-- END catrow_noalb -->
and change colspan="3" to colspan="9"

and find
Quote
<!-- BEGIN footer -->
        <tr>
                <td colspan="3" class="tableh1" align="center"><span class="statlink"><b>{STATISTICS}</b></span></td>
        </tr>
<!-- END footer -->
and do the same

I may have miss an extra one, but that's the idea

-matt-

cwapface

perfect, thank you so much for the help!

Jupiter184

#12
Many thanks for all the above.  I am trying to get my categories into two columns as well.  I followed the instructions but ended up with this:
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.jupiterwill.co.uk%2Ftesting%2FPrintscreen190305th.jpg&hash=b8815c49d003f56c0f4a232a1556794ead835125)
This is my test gallery.  The real gallery I am working on has 7,000 images!

Any ideas?  

ETA: I worked it out.  Necessity is the mother of invention, and prompted me to improve my PHP skills.  I had both catrow and catrow_noalb, and has only taken the <tr> and </tr> out on one of them in the template.

ve.ru

It seems like you just changed the table header but  you didn't delete the <tr> and </tr> after <!-- BEGIN catrow --> (look at step 2).

Regards,
Verena

cwapface

sorry for resurrecting this thread, i have one more question.  My categories are in 3 columns as solved by you guys above, but if I go into a subcategory they are still all in a list on the left hand side.  If the settings to change aren't in themes.php, where would I find them?

Warlock82

Before I try this out, I was curious if this will mix catagories in with albums or if they will still be seperate.  For example, something like:

[album1] [album2]
[album3] [catagory1]

rather than:
[album1] [album2]
[album3] [empty]
[catagory1] [empty]

I'd really like to have them mixed in but it looks like they won't be with this (from what I've seen of other people's galleries who have tried it)

stock

sorry if this is posted twice but I can't find where my post has gone!

I have used ve'ru's code to change my front page to three columns. This has worked to a certain extent, but you can see the problems in the picture below. I want the strap line (categories) to be just one line and have I thought deleted the albums and pictures number columns, but maybe not properly. Also, as you can see, the cats them selves have a gap at the top of the second and third column. This is so nearly what I want and have been searching for for ages that I would be very grateful for any suggestions to make this work.

thanks

Stock

stock

I'm not sure if this thread is still live but I will post a new enquiry after a while if not as it looks dead. Please advise. Thanks

Please note I have fixed the line above my images (see screen shot previous post) and now all I am trying to do is get the thumbnails not to have a gap at top of 2nd and 3rd column.

Can anybody please help

Stock

MadPole

#18
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 Gallery

1. Template sections

replace 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 function

Replace 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.....