Trouble getting catagories to list in columns properly Trouble getting catagories to list in columns properly
 

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

Trouble getting catagories to list in columns properly

Started by pcbill, July 07, 2006, 07:24:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pcbill

I have modified my theme.php trying to achieve a list of categories listed in 3 columns wide without the file & album counts. I have been following this thread and have tied to duplicate what is laid out in the last message:
http://forum.coppermine-gallery.net/index.php?topic=15400.msg107765#msg107765
It was written for an older version and puts things in a 2 column listing. The one thing I liked about MadPole's version was it dealt with the problem that would occur with when you had only a partially filled row.

I have also added the ability to put a thumbnail behind a category that doesn't have an album. This is mod is for other files so I don't think it's directly is causing my issue. However I followed this thread for that mod.
http://forum.coppermine-gallery.net/index.php?topic=33310.0

So my problem is the theme file is handling "categories with no albums" different than "categories with albums" For those with no album it is inserting  </tr> </tr> <tr><tr> after each Category forcing the next one to the next row.
The following is the code the template is outputting:
<!-- Start standard table -->
<table align="center" width="90%" cellspacing="1" cellpadding="0" class="maintable">

        <tr>
<td class="tableh1" width="33%"><b>Category</b></td>
<td class="tableh1" width="33%">&nbsp;</td>
                <td class="tableh1" width="34%">&nbsp;</td>
        </tr>
<tr>
        <tr>
                <td class="tableh2"><table border="0"><tr><td><a href="index.php?cat=2"><img src="albums/userpics/10001/t_2005d0461.jpg" class="image" width="35" height="50" border="0" alt="" /></a></td><td><span class="catlink"><b><a href="index.php?cat=2">Cat 1</a></b>
</span></td></tr></table></td>
        </tr>
</tr> <tr>
        <tr>
                <td class="tableh2"><table border="0"><tr><td><a href="index.php?cat=4"><img src="albums/test/testpics/t_690_504_full.jpg" class="image" width="50" height="47" border="0" alt="" /></a></td><td><span class="catlink"><b><a href="index.php?cat=4">Cat 2</a></b>
</span></td></tr></table></td>
        </tr>
</tr> <tr>
        <tr>
                <td class="tableh2"><table border="0"><tr><td><a href="index.php?cat=6"><img src="albums/test/testpics/t_690_503_full.jpg" class="image" width="50" height="47" border="0" alt="" /></a></td><td><span class="catlink"><b><a href="index.php?cat=6">Cat 3</a></b>
</span></td></tr></table></td>
        </tr>
</tr> <tr></tr>
        <tr>
                <td colspan="3" class="tableh1" align="center"><span class="statlink"><b><b>13</b> files in <b>8</b> albums</b></span></td>
        </tr>
</table>
<!-- End standard table -->


The following is the result I am after:
<!-- Start standard table -->
<table align="center" width="90%" cellspacing="1" cellpadding="0" class="maintable">

        <tr>
<td class="tableh1" width="33%"><b>Category</b></td>
<td class="tableh1" width="33%">&nbsp;</td>
                <td class="tableh1" width="34%">&nbsp;</td>
        </tr>
<tr>
        <tr>
                <td class="tableh2"><table border="0"><tr><td><a href="index.php?cat=2"><img src="albums/userpics/10001/t_2005d0461.jpg" class="image" width="35" height="50" border="0" alt="" /></a></td><td><span class="catlink"><b><a href="index.php?cat=2">Cat1</a></b>
</span></td></tr></table></td>
                <td class="tableh2"><table border="0"><tr><td><a href="index.php?cat=4"><img src="albums/test/testpics/t_690_504_full.jpg" class="image" width="50" height="47" border="0" alt="" /></a></td><td><span class="catlink"><b><a href="index.php?cat=4">Cat 2</a></b>
</span></td></tr></table></td>
                <td class="tableh2"><table border="0"><tr><td><a href="index.php?cat=6"><img src="albums/test/testpics/t_690_503_full.jpg" class="image" width="50" height="47" border="0" alt="" /></a></td><td><span class="catlink"><b><a href="index.php?cat=6">Cat 3</a></b>
</span></td></tr></table></td>
        <tr>
                <td colspan="3" class="tableh1" align="center"><span class="statlink"><b><b>13</b> files in <b>8</b> albums</b></span></td>
        </tr>
</table>
<!-- End standard table -->


The code listed below are both sections of my theme.php file:

// Start Column Mod
// HTML template for the category list
$template_cat_list = <<<EOT

<!-- BEGIN header -->
        <tr>
<td class="tableh1" width="33%"><b>{CATEGORY}</b></td>
<td class="tableh1" width="33%">&nbsp;</td>
                <td class="tableh1" width="34%">&nbsp;</td>
        </tr>
<!-- END header -->

// "colspan=3" was removed below under <td class="tableh2"> spanning this to 3 cells should cause the column count problems below ??
<!-- BEGIN catrow_noalb -->
        <tr>
                <td class="tableh2"><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 -->
// The <tr> </tr> above around <td class="table2"> may not belong there. I have tried them and it seems to produce the wrong results when you go into a catagory that is mixed with catrow_noalb & catrow entries?
<!-- 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>
<!-- END catrow -->
<!-- BEGIN catrow_blank -->
                <td class="tableb" align="center"></td>
        </tr>

<!-- END catrow_blank -->
//        <tr>
//            <td class="tableb" colspan="6">{CAT_ALBUMS}</td>
//        </tr>
// above causes errors  not sure why?? Was before he end of catrow blank
<!-- BEGIN footer -->
        <tr>
                <td colspan="3" class="tableh1" align="center"><span class="statlink"><b>{STATISTICS}</b></span></td>
        </tr>
<!-- END footer -->
<!-- BEGIN spacer -->
        <img src="images/spacer.gif" width="1" height="17" alt="" /><br />
<!-- END spacer -->
EOT;
//End Column Mod


and

// Start add of funtion theme for Column Mod
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=3;
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],
);
$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],
);
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');
}
// End Mod Column Mod


In the <!-- BEGIN catrow_noalb --> section there are <tr></tr> still surrounding the <td> section which I believe are causing one set of extra the tags above. I have tried removing this and it doesn't solve the problem and actually messes up the page of subcategories should you click one of the listed categories.

In the function section of the code that reads if ($count%$columnCount==0) {      echo "</tr> <tr>"; I believe, is adding the section set. The problem is if these are not there or you change the varible when you have more than three categories they never get the necessary  </tr> <tr>  and are all run on the same row.

I am guessing there is some incorrect coding or setting of the count variable causing this. I don't know enough of the php language to understand what each line is doing here to try and figure out what is wrong. I have tried various changes and obviously none were write.

Does anybody see where the problem(s) are with what I have now.

Thanks (again),

Bill

Stramm

copy this in your theme.php
// HTML template for the category list
$template_cat_list = <<<EOT
<!-- BEGIN header -->
        <tr>
        <tr>
                <td class="tableh1" width="25%"><b>{CATEGORY}</b></td>
                <td class="tableh1" width="4%" align="center"><b>{ALBUMS}</b></td>
                <td class="tableh1" width="4%" align="center"><b>{PICTURES}</b></td>
<td class="tableh1" width="26%"><b>{CATEGORY}</b></td>
                <td class="tableh1" width="4%" align="center"><b>{ALBUMS}</b></td>
                <td class="tableh1" width="4%" align="center"><b>{PICTURES}</b></td>
<td class="tableh1" width="25%"><b>{CATEGORY}</b></td>
                <td class="tableh1" width="4%" align="center"><b>{ALBUMS}</b></td>
                <td class="tableh1" width="4%" align="center"><b>{PICTURES}</b></td>
        </tr>
        </tr>
<!-- END header -->
<!-- BEGIN catrow_noalb -->
                <td class="catrow_noalb" colspan="3"><table border="0"><tr><td align="left">{CAT_THUMB}</td><td align="left"><span class="catlink"><b>{CAT_TITLE}</b></span>{CAT_DESC}</td></tr></table></td>
<!-- END catrow_noalb -->
<!-- BEGIN catrow -->
                <td class="catrow" align="left"><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="catrow" align="center">{ALB_COUNT}</td>
                <td class="catrow" align="center">{PIC_COUNT}</td>

<!-- END catrow -->
<!-- BEGIN footer -->
        <tr>
                <td colspan="9" class="tableh1" align="center"><span class="statlink"><b>{STATISTICS}</b></span></td>
        </tr>
<!-- END footer -->
<!-- BEGIN spacer -->
        <img src="images/spacer.gif" width="1" height="7" border="" alt="" /><br />
<!-- END spacer -->

EOT;

function theme_display_cat_list($breadcrumb, &$cat_data, $statistics)
{
    global $template_cat_list, $lang_cat_list;
    if (count($cat_data) > 0) {
        starttable('100%');
        $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%$columnCount==0) {
    echo "</tr><tr>";
}
        $count++;
        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);
        } elseif (isset($category['cat_albums']) && ($category['cat_albums'] != '')) {
            $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],
                );
            echo template_eval($template, $params);
        } else {
            $params = array('{CAT_TITLE}' => $category[0],
                '{CAT_THUMB}' => $category['cat_thumb'],
                '{CAT_DESC}' => $category[1],
                '{CAT_ALBUMS}' => '',
                '{ALB_COUNT}' => $category[2],
                '{PIC_COUNT}' => $category[3],
                );
            echo template_eval($template, $params);
        }
    }
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);
    }


    if (count($cat_data) > 0)
          endtable();
        echo template_extract_block($template_cat_list, 'spacer');
}

pcbill

Thanks very much, seems to be displaying correctly.

In my attempt, I removed the Album & Pic count as I doubt they will matter to my visitors. As you put them back in is it not possible / feasible to remove them?

Bill

Stramm

You can safely remove the category stats if you don't need them

pcbill

Thanks, it's all working good.

Btw -took a look at your gallery. You have some nice underwater stuff.

Bill

dellwo

Didn't work for me.
I'm using the Fruity theme and if I don't have the same number of categories as cells in the table, the final cells don't get the background color.
Also, when I click on a category, the album list is shifted down so it's below the buttons on the left.

I sure wish they would add this to the config panel.

[I got a -1 Karma for this post?? You're kidding. It's an appropriate response to this thread. I searched the forum several times and this thread just about got me where I wanted to be. You guys really need to lighten up.]

ausdlk

I followed the guidelines in this thread (more or less) to remove the "Albums" and "Files" columns from the Categories page in the Project VII theme (themes.inc.php) and to have three columns each with a thumbnail and description. Thanks to all who went before me. (www.david-keenan.com)

Joachim Müller

you mustn't edit include/themes.inc.php, but themes/yourtheme/theme.php

charlie5000

Hi

I use the themes I-fell-dirty, and I copy the kode in me theme.php (The kode from the user stramm) Put nothing happen, It still look the same, can anyone help me?

Joachim Müller

Then post a link to your gallery and attach a zip of your custom theme folder to your posting (using "additional options" when composing your message).

heartsy

First let me say I am totally new to this, and it's been a couple of years since I did any basic html coding. Just to make sure anyone who helps me understands that I am totally clueless, lol. The link to my gallery is http://heartsy.com/gallery/ , as you can see I used the eyeball theme and just changed the images to a red version and changed the text colors in the style sheet thing. I want my catagories to display across the top of the gallery and the albums to drop down the page...basically the exact opposite of what it does now. If you notice two of my catagories are private and one isn't.. I want anyone that views my site to see there is photos that are viewable to anyone. And only having 3 catagories it will display them all perfectly the other way.. and only having to scroll to choose an album just makes more sense to me anyway. So yeah can anyone tell me what to change and where in the code to find it... I would really appreciate it.... thanks

Joachim Müller

Did you read my posting just above yours? Any particular reason for not doing as I suggested there?

heartsy

yes I did read the message... I just somehow missed the attach a zip of theme folder... umm hope I'm doing this right.
link once again is http://heartsy.com/gallery it's not really custom, all I did was change font colors and image colors. And attaching the zip file.. hope this works, sorry never did this before.

Joachim Müller

You just failed to follow the most basic instructions posted by Stramm in his initial posting on this thread - you haven't copied the piece of code he mentioned into your custom theme.php.

I have done this for you (and cleaned up your custom theme a bit). Additionally, I renamed your custom theme - you should always do so (as suggested in http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#theme_create_rename). Unzip the attachment and extract it (preserving the structure of the archive) into your themes folder (http://heartsy.com/gallery/themes/). Then preview your new custom theme by going to http://heartsy.com/gallery/?theme=eyeball_custom
If you like the result, go to coppermine's config and select the new theme (eyeball_custom) as you default theme.

Please understand that what I did for you is beyond what you can usually expect from free support - you haven't even tried to do as suggested in this thread - just saying "I'm a newbie, explain it to me" is not a bright thing; don't expect to be spoon-fed in the future.

Joachim

heartsy

Again, I apoligize... I guess when I read the begining of this thread I misunderstood what was there. I thought they were not only talking about putting the catagories into colums but removing the album thumbnails as well? Which was not quite what I wanted to do. Needless to say I was afraid that if I pasted that code I would goof things up and still not get the result I wanted. Thank you very much for you help...I did not expect anyone to do the work for me, but I do appreciate it. Can I ask 2 more small things though... as I want to learn how to do this myself. One, you said you cleaned the code up a bit.. when I edited the script, not really knowing what I was doing, (I've only really done HTML and some very basic Java Editing before)..the program that opened it and allowed me to edit auto like on my computer was Dreamweaver...should I not use that in the future? Did it add to the code? I know Frontpage will do that, and to keep HTML clean a simple it's best to just use notepad, so wondering if I can and should do that with the script for my guestbook. And two, is the only thing you had to edit the script itself? That way I can print out copy and compare it to original to see exactly what you did, so I can learn from it. Once again thank you... I'll go try it out now.

heartsy

ok got it uploaded, and maybe I was right about that code above...cuz the ablum views are gone? Is there a way to keep those and just have them display down the colums instead of being gone all together? If not I guess this will work better then the other way and I'll live with it. Still gonna print and compare, maybe I can figure it out. Oh and on the renaming thing.. I tried that, originally I dled a copy of eyeball theme to my computer, edited the style sheet, changed theme name, uploaded it, and it showed all the old images, the blue still. Of course I realized that was because it was pointing to eyeball/images so I changed the code on the images to point to my edited folder, and I don't know what I did wrong, but it completely goofed, images didn't show, and the page didn't display right. Not knowing what I did wrong, I couldn't fix it. So I opted to rename the images folder and the style sheet to imagesOld..etc, that way I could always put everything back if something went wrong. And it worked. Anyway, thanks again for your help. I will go study the code, and in the meantime if there is a way to make the albums still show up, can you let me know?

heartsy

ok, I studied codes on all 3 parts... I noticed all you really did on the style sheet and template.html was delete some of the blank lines, and of course make sure all links pointed to the right files being that you renamed them. I also realized that my problem with renaming things, was I forgot to rename things in the theme.php, and I imagine that's why my page didn't show up correctly when I tried to rename things myself. And of course I saw you pasted a code at the very bottom of the php file. Which for all intents and purposes did display the catagories in colums instead of rows, part of which is what I wanted... but you overlooked the part of keeping the album thumbs as well. So I decided that I would first try the easy way and go in thru config settings, see if I could find something that would make them display again... then I found a big problem in your code. I hit log in, it took me to that page, signed in, it took me to page saying welcome blah blah.. I hit the continue button and back at the main page again, which is all normal, except one very important part I was no longer logged in. Whatever you did won't work, unless you want to be locked out of your own guestbook. I almost uninstalled the whole works so I could start over, but luckily I remembered I did have my copy of the original php file, which I uploaded and replaced your edited file with, and it worked got me back into my guestbook settings... So, I hate to say it, but code doesn't work quite right. Maybe it was pasted in the wrong place, or maybe it needs something more to it, I don't know. So back to square one.......

Joachim Müller

Quote from: heartsy on November 26, 2007, 09:53:25 PM
Can I ask 2 more small things though...
No - we have a strict "one question per thread" policy that you agreed to respect when signing up. You hijacked someone else's thread already, which is not a bright idea in the first place. Cluttering that thread even further with additional questions is not nice in terms of respect for board rules.

Quote from: heartsy on November 26, 2007, 09:53:25 PMthe program that opened it and allowed me to edit auto like on my computer was Dreamweaver...should I not use that in the future? Did it add to the code? I know Frontpage will do that, and to keep HTML clean a simple it's best to just use notepad, so wondering if I can and should do that with the script for my guestbook.
Don't use Frontpage nor Dreamweaver to edit PHP code unless you know what you're doing: both a WYSIWYG-editors that tend to mess with the code. Why do you have dreamweaver, which is a commercial application if you have no idea how to edit HTML in the first place? Notepad.exe is fine, but you might want to use an improved free editor that has syntax highlighting and such stuff. See "Tools recommended by the devs"

Quote from: heartsy on November 26, 2007, 09:53:25 PMThat way I can print out copy and compare it to original to see exactly what you did, so I can learn from it.
Try Winmerge to compare code.

Quote from: heartsy on November 27, 2007, 02:59:57 AM
So, I hate to say it, but code doesn't work quite right. Maybe it was pasted in the wrong place, or maybe it needs something more to it
I tested the code I posted on my testbed before zipping it - it worked fine. It's impossible that it broke your guestbook or whatever. Maybe you applied it incorrectly.

As suggested above: this is not your thread - you hijacked it in the first place. Asking unrelated stuff is not a bright idea. Locking this thread now.