Advanced search  

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

Pages: [1]   Go Down

Author Topic: categories in columns  (Read 24191 times)

0 Members and 1 Guest are viewing this topic.

ve.ru

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 26
categories in columns
« on: October 30, 2004, 06:05:27 pm »

Hi,

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

thanks,
verena
« Last Edit: March 07, 2005, 08:45:49 am by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: categories in columns
« Reply #1 on: October 31, 2004, 07:48:17 am »

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

Joachim
Logged

ve.ru

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 26
Re: categories in columns
« Reply #2 on: November 02, 2004, 11:50:48 pm »

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
Logged

mid0ri

  • Coppermine newbie
  • Offline Offline
  • Gender: Female
  • Posts: 14
Re: categories in columns
« Reply #3 on: November 05, 2004, 01:32:06 am »

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

ve.ru

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 26
Re: categories in columns
« Reply #4 on: November 05, 2004, 01:34:33 pm »

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
Code: [Select]
$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:

Code: [Select]
<!-- 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
Code: [Select]
<!-- BEGIN catrow -->and delete the <tr> and </tr> tag in the following lines

Go to line
Code: [Select]
<!--if (isset(CAT_ALBUMS)){-->
and delete everything until

Code: [Select]
<!--};-->
Now look for the function
Code: [Select]
function theme_display_cat_list($breadcrumb, &$cat_data, $statistics)
Go to the line
Code: [Select]
foreach($cat_data as $category) {
and isert before (outside the foreach loop):
Code: [Select]
    $count=0;
    $columnCount=2;
    echo "<tr>";

and now insert after this line (inside the foreach loop):
Code: [Select]
If ($count%$columnCount==0) {
    echo "</tr><tr>";
}
        $count++;

Go to the line
Code: [Select]
    if ($statistics && count($cat_data) > 0) {
and insert before:
Code: [Select]
echo "</tr>";
That's it! now you have to columns with categories.
regards,
Verena
Logged

mid0ri

  • Coppermine newbie
  • Offline Offline
  • Gender: Female
  • Posts: 14
Re: categories in columns
« Reply #5 on: November 09, 2004, 10:03:01 am »

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
Logged

ve.ru

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 26
Re: categories in columns
« Reply #6 on: November 09, 2004, 07:33:38 pm »

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
Logged

mid0ri

  • Coppermine newbie
  • Offline Offline
  • Gender: Female
  • Posts: 14
Re: categories in columns
« Reply #7 on: November 17, 2004, 05:13:15 am »

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)
Logged

cwapface

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
category columns problem
« Reply #8 on: March 01, 2005, 05:40:02 pm »

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

Code: [Select]
// 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 -->


Code: [Select]
<!-- 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 -->


Code: [Select]
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');
}

Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: categories in columns
« Reply #9 on: March 02, 2005, 08:18:39 am »

merged your question with the thread you were refering to.

Joachim
Logged

nol33t

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 244
  • Exploring Coppermine in every directions
    • tieum's pics
Re: categories in columns
« Reply #10 on: March 02, 2005, 09:31:48 am »

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

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: categories in columns
« Reply #11 on: March 02, 2005, 10:11:41 pm »

perfect, thank you so much for the help!
Logged

Jupiter184

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: categories in columns
« Reply #12 on: March 19, 2005, 07:57:05 pm »

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:
(http://www.jupiterwill.co.uk/testing/Printscreen190305th.jpg)
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.
« Last Edit: March 20, 2005, 05:26:23 pm by Jupiter184 »
Logged

ve.ru

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 26
Re: categories in columns
« Reply #13 on: April 22, 2005, 10:22:13 am »

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
Logged

cwapface

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: categories in columns
« Reply #14 on: September 14, 2005, 09:28:20 pm »

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?
Logged

Warlock82

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: categories in columns
« Reply #15 on: September 23, 2005, 02:32:45 pm »

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)
Logged

stock

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 109
Re: categories in columns
« Reply #16 on: September 24, 2005, 06:20:39 pm »

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
Logged

stock

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 109
Re: categories in columns
« Reply #17 on: September 24, 2005, 09:24:47 pm »

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
Logged

MadPole

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
    • MadPole & Co Visual Arts Gallery
Re: categories in columns
« Reply #18 on: November 05, 2005, 07:27:35 pm »

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:

Code: [Select]
<!-- 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)

Code: [Select]
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.....
« Last Edit: November 05, 2005, 07:38:13 pm by MadPole »
Logged
Pages: [1]   Go Up
 

Page created in 0.07 seconds with 19 queries.