Drop Down List Categories Drop Down List Categories
 

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

Drop Down List Categories

Started by psylocke, March 14, 2007, 12:25:06 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

psylocke

HI, someone can tell me what mod is this one?

http://www.chocolate-fish.net/

The drop down menu to the categories?
I saw a mod about this but it didn't help :(



Joachim Müller

The page you refered to is hacked beyond recognition (with the "Powered by Coppermine" tag removed), but basically, it is running the outdated cpg1.3.3, which goes unsupported. The owner of the site probably applied the hack himself and did not publish it. I don't think a hack like the one you have posted has been published (yet). Bottom line: I have no idea where to get this hack from.

Hein Traag

Not sure if this does the same but you might want to try it and let us know if it worked for you.
http://forum.coppermine-gallery.net/index.php?topic=32108.0

psylocke

Quote from: Hein on March 14, 2007, 08:34:11 AM
Not sure if this does the same but you might want to try it and let us know if it worked for you.
http://forum.coppermine-gallery.net/index.php?topic=32108.0

Exactly this one that I didn't get the first part:

Quote
First thing you need to do is enable anycontent.php in your admin settings, and hopefully it will show on the top of your board, if not then your going to have to edit your theme.php and make anycontent.php display where ever you want the drop down lists to appear.

Hein Traag

Now is the time to start searching the board and reading documentation.

onr

Not sure if this is still needed but the modification to get the drop downs are as follows:

In theme.php find catrow and change it to
Quote
<!-- BEGIN catrow -->
      <tr>
         <td class="tableb"><table border="0"><tr><td width="170">{CAT_THUMB}</td><td><span class="catlink"><b>{CAT_TITLE}</b></span><span class="tableh2_catdesk">{CAT_DESC}<br><br><select class="listbox_albs" NAME="albums" onchange="document.location=this[this.selectedIndex].value">
               <OPTION VALUE="" SELECTED> - {CAT_TITLE} - </OPTION>{DROP_MENU}</select></span></td></tr></table></td>
      </tr>
<!-- END catrow -->
(Note that some class tags might be different for you as I have modified them. )
Now find: function theme_display_cat_list in theme.php
in this function find:
Quote
foreach($cat_data as $category) {
        if (count($category) == 3) {
            $params = array('{CAT_TITLE}' => bb_decode($category[0]),
                '{CAT_THUMB}' => $category['cat_thumb'],
                '{CAT_DESC}' => bb_decode($category[1])
                );
            echo template_eval($template_noabl, $params);
        } else {
            $params = array('{CAT_TITLE}' =>  bb_decode($category[0]),
                '{CAT_THUMB}' => $category['cat_thumb'], //cat_pic($category[0]),
                '{CAT_DESC}' => bb_decode($category[1]),
                '{CAT_ALBUMS}' => $category['cat_albums'],
                '{ALB_COUNT}' => $category[2],
                '{PIC_COUNT}' => $category[3],             
                );
            echo template_eval($template, $params);           
        }   
and change it to
Quote
foreach($cat_data as $category) {
        if (count($category) == 3) {
            $params = array('{CAT_TITLE}' => bb_decode($category[0]),
                '{CAT_THUMB}' => $category['cat_thumb'],
                '{CAT_DESC}' => bb_decode($category[1])
                );
            echo template_eval($template_noabl, $params);
        } else {
            $params = array('{CAT_TITLE}' =>  bb_decode($category[0]),
                '{CAT_THUMB}' => $category['cat_thumb'], //cat_pic($category[0]),
                '{CAT_DESC}' => bb_decode($category[1]),
                '{CAT_ALBUMS}' => $category['cat_albums'],
                '{ALB_COUNT}' => $category[2],
                '{PIC_COUNT}' => $category[3],
                '{DROP_MENU}' => $category['dropmenu'],
                );
            echo template_eval($template, $params);           
        }   
i.e. you add one line with the DROP_MENU item.

In index.php find: function get_subcat_data

Find the if-condition:
Quote
if ($subcat['cid'] == USER_GAL_CAT) { ...

else ...

in the else block add the following code
Quote
// -------------------- added the drop down menus for the category list ---------------
                $menutxt = '';
                $names = '';
                $link_txt = '';                                     
                $sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = {$subcat['cid']}";
                  $result = db_query($sql);                  
                  $num_albs= mysql_num_rows($result);                    
                for ($counter=0; $counter < $num_albs; $counter +=1){                                 
                   $album_id = mysql_fetch_array($result);
                    $sql = "SELECT title FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = {$album_id[0]}";
                     $rresult = db_query($sql);                                    
                    $country = mysql_fetch_array($rresult);                
                    $names[$counter] = ucwords(bb_decode($country[0]));
                    $link_txt[$counter] = "album_".$album_id[0];                     
                    mysql_free_result($rresult);       
                 }                                 
                 $ccounter=$counter;
                    mysql_free_result($result);       
                    // now the categories
                    $sql = "SELECT cid FROM {$CONFIG['TABLE_CATEGORIES']} WHERE parent = {$subcat['cid']}";
                  $result = db_query($sql);
                  $num_cats = mysql_num_rows($result);                 
                  if ($num_cats) {
                    for ($counter=0; $counter < $num_cats; $counter +=1){                       
                       $scat_id = mysql_fetch_array($result);   
                       $sql = "SELECT name FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = {$scat_id[0]}";
                        $rresult = db_query($sql);                                    
                       $country = mysql_fetch_array($rresult);
                       $names[$ccounter + $counter +1] = bb_decode($country[0]);
                       $link_txt[$ccounter + $counter +1] = "category_".$scat_id[0];
                       mysql_free_result($rresult);   
                    }                  
                     mysql_free_result($result);       
                  }
                  array_multisort($names,$link_txt);                 
                  $totalnum=count($names);
                     for ($counter=0; $counter < $totalnum; $counter +=1){                       
                       $menutxt .= "<OPTION VALUE='".$link_txt[$counter]."'>".$names[$counter]."</OPTION>";
                    }                                      
This reads in all albums that belong to a particular category and sorts them alphabetically. Below this you need to modify the if/else condition to something like this:
Quote
if ($pic_count == 0 && $album_count == 0) {
                                        $user_thumb = $ident;
                    $cat_data[] = array($link, $subcat['description'],'cat_thumb' =>$user_thumb);
                } else {
                    // Check if you need to show subcat_level
                    if ($level == $CONFIG['subcat_level']) {
                        $cat_albums = list_cat_albums($subcat['cid']);
                    } else {
                         $cat_albums = '';
                    }                   
                    $cat_data[] = array($link, $subcat['description'], $album_count, $pic_count, 'dropmenu' => $menutxt, 'cat_albums' => $cat_albums,'cat_thumb' =>$user_thumb);
                }
i.e. you add the 'dropmenu' item in the $cat_data vector.
OK I think this should do it.


onr

P.S.: I forgot to mention that I hada mod_rewrite which maps something like almbum_xx onto thumbnails.php?album=xx to make it more SE friendly and the same for category, so in the code that I posed, the $link_txt variables might look different for you, e.g.
Quote
$link_txt[$counter] = "thumbnails.php?album=".$album_id[0];
instead of
Quote
$link_txt[$counter] = "album_".$album_id[0];
and for category:
Quote
$link_txt[$counter] = "index.php?cat=".$album_id[0];
instead of
Quote
$link_txt[$counter] = "category_".$album_id[0];
Note that my countries are in different languages hence I use the bb_decode function.
As GauGau said it's all hacked beyond recognition so it won'T be easy to include it but with the info above it should work.

antisa33

Hello
I need a drop down category list on my template.html
I can understand your code but this is for theme.php
How can i do ?
Thanks!!

Joachim Müller

Not at all. template.html can only contain static HTML, but not dynamic PHP. It's pretty easy to code something in theme.php that then later shows up on your gallery. Start a new thread with a link to your gallery and post there what PHP code you need to display in which section of your pages. Attach your zipped custom theme to that thread as well.

onr

#9
Quote from: antisa33 on October 03, 2007, 10:00:48 PM
Hello
I need a drop down category list on my template.html
I can understand your code but this is for theme.php
How can i do ?
Thanks!!

Since antisa33 emailed me about this I sent her the following reply. Maybe this is usefully to others as well. If it is appropriate to put this into a new thread then please move it.

Ok so here it goes:

In template.html put this

{QUICKJUMP_MENU} 


wherever on your pages you want the drop down menu to appear.

In functions.inc.php search the function "load _template()" and add these 2 lines:

$gallery_pos = strpos($template, '{QUICKJUMP_MENU}');
$template = str_replace('{QUICKJUMP_MENU}', quickjumpmenu() ,$template);


Then also in functions.inc.php I have written this function:


function quickjumpmenu() {
  global $CONFIG;
  global $lang_index_php, $lang_list_categories, $lang_code; 
       
        include 'include/album_structure_'.$lang_code.'.php';
        $menutxt = '';               
        if (!($_SERVER['PHP_SELF'] == '/index.php' & (substr($_SERVER['QUERY_STRING'],0,3) == 'lan' | $_SERVER['QUERY_STRING'] == '')) & !($_SERVER['PHP_SELF'] == '/sitemap.php')){
                 
                                         $menutxt .= "<TD align='right'> <Font color='#666666'><select class='listbox_albs' ID='quick_jump' NAME='quick_jump' onchange='document.location=this[this.selectedIndex].value'><OPTION VALUE='' SELECTED> - {$lang_index_php['quick_links']} - </OPTION>";                                                                                                                                           
                           for ($counter=0; $counter < (count($cnames)); $counter +=1) {                                                                                               
                                if (count($snames[$cnames[$counter]]) > 1){ // we have sub items
                                        for ($subcounter=0; $subcounter < (count($snames[$cnames[$counter]])); $subcounter +=1) {
                                                                                        $menutxt .= "<OPTION VALUE='/".$slink[$cnames[$counter]][$subcounter]."'>".$cnames[$counter]." - ".$snames[$cnames[$counter]][$subcounter]."</option>";                                                                                 
                                                                        }                                       
                                } elseif (count($snames[$cnames[$counter]]) == 1){ // we have only the bw sub items
                                        $menutxt .= "<OPTION VALUE='/".$clink[$counter]."'>".$cnames[$counter]."</option>";                                                                                     
                                                                        $menutxt .= "<OPTION VALUE='/".$slink[$cnames[$counter]][0]."'>".$cnames[$counter]." - ".$snames[$cnames[$counter]][0]."</option>";                                                                                                                                                                                                     
                                } else {
                                        $menutxt .= "<OPTION VALUE='/".$clink[$counter]."'>".$cnames[$counter]."</option>";
                                }
                                                        }                                                       
                          $menutxt .= "</font></select></td></tr></table>";                                     
           }           
           return $menutxt;
}


The first if condition basically prevents the menu to appear on the front page and on my sitemap. The crucial thing there is the line:

include 'include/album_structure_'.$lang_code.'.php';


so I don't generate the menu on the fly but read in the info from the a file. I decided to do it this way since the album structure is fairly static anyway and if you would do it dynamically then you would have to do a database query whenever someone looks at a page (ontop of all the other queries) which seemed unnecessary. So instead I have six files called album_structure_$lang_code.php' where $lang_code is either "en" "de" etc. for the six languages I have on the site. I generate these files with a php script file that I execute whenever I do some changes in the album structure. The relevant part of this file for you is this:

<?php 
/**
File to create the XML files for the Flash movies and also the album structure that is
used in the bottom_txt() function and also in the quickjumpmenu and in the album text
in the flash box.
*/
define('IN_COPPERMINE'true);
define('INDEX_PHP'true);

require(
'include/init.inc.php');
global 
$CONFIG$lang_code;

pageheader('Update XML and album structure');

echo 
'</tr></table>';
starttable(690'Make XML files');
echo 
'<TR><TD CLASS="order">';
update_albums();
echo 
'</TD></TR"></Table>';
ob_end_flush();

/*
End of Main code
*/

/*
UPDATE ALBUM STRUCTURE
*/
function update_albums() {
        global 
$CONFIG$lang_code;
        
        
$selected_lang=$lang_code;                    
        
$langs = array('en','fr','de','it','es','pt');
        for (
$langcount=0$langcount 6$langcount++) {
                
$all '';
                
$cnames '';
    
$clink '';
          
$snames '';
          
$slink '';
          
$toplevel '';
          
$topalblocs '';
          
$salblocs '';
          
$lnk_txt '';

                
$lang_code=$langs[$langcount];
          
$sql "SELECT title FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid= 19"//USA for bw New York album
          
$esult db_query($sql);
          
$USA=mysql_fetch_array($esult);
          
mysql_free_result($esult);
                
          
$sql "SELECT cid,name FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid > 1 AND parent = 0 ORDER by pos";  // top level categories (not used)
    
$esult db_query($sql);
    
$count=0;                                                                                           
    while (
$rrrow mysql_fetch_array($esultMYSQL_NUM)) {  
        
$sql "SELECT name,cid FROM {$CONFIG['TABLE_CATEGORIES']} WHERE parent=$rrrow[0]";
      
$result db_query($sql);                                                                                                 
      while (
$row mysql_fetch_array($resultMYSQL_NUM)) {
        
$cnames[$count] = bb_decode($row[0]);
                        
$clink[$count] = 'category_'.$row[1];   
                        
$topalblocs[$count] = '';               
                        
$toplevel[$count] = $rrrow[0];
                        
$sql "SELECT title,aid,description FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = $row[1]";
                        
$rresult db_query($sql);
                        
$sub_count=0;
                        while (
$rrow mysql_fetch_array($rresultMYSQL_NUM)) {
                        
$snames[$cnames[$count]][$sub_count] = bb_decode($rrow[0]);
                                
$slink[$cnames[$count]][$sub_count] = 'album_'.$rrow[1];                        
                                
$salblocs[$cnames[$count]][$sub_count] = stripos(bb_decode($rrow[2]),'<i>') ?  substr(bb_decode($rrow[2]), stripos(bb_decode($rrow[2]),'<i>')) : bb_decode($rrow[2]);
                                
$sub_count=$sub_count+1;
                        }                                       
                        
array_multisort($snames[$cnames[$count]],$slink[$cnames[$count]],$salblocs[$cnames[$count]]);                   
                        
$count=$count+1;
                        
mysql_free_result($rresult);
                }
                
$sql "SELECT title,aid,description FROM {$CONFIG['TABLE_ALBUMS']} WHERE category=$rrrow[0]";
                
$result2 db_query($sql);
                while (
$row mysql_fetch_array($result2MYSQL_NUM)) {                         
                        if (
$rrrow[0]==&& $row[1]>&& $row[1]!=5) { //bw                             
                                        
$snames[bb_decode($row[0])][count($snames[bb_decode($row[0])])] = bb_decode($rrrow[1]); // we don't use [0] here so the bw gets sorted after the colour albums
                                        
$slink[bb_decode($row[0])][count($slink[bb_decode($row[0])])] = 'album_'.$row[1];                                       
                                        
$salblocs[bb_decode($row[0])][count($slink[bb_decode($row[0])])-1] = stripos(bb_decode($row[2]),'<i>') ?  substr(bb_decode($row[2]), stripos(bb_decode($row[2]),'<i>')) : bb_decode($row[2]);
                        } elseif (
$row[1]==5) {
                                
$snames[bb_decode($USA[0])][0] = bb_decode($row[0]).' ('.bb_decode($rrrow[1]).')';
                                
$slink[bb_decode($USA[0])][0] = 'album_'.$row[1];                                                                               
                                
$salblocs[bb_decode($USA[0])][0] = stripos(bb_decode($row[2]),'<i>') ?  substr(bb_decode($row[2]), stripos(bb_decode($row[2]),'<i>')) : bb_decode($row[2]);
                        } else { 
// top level albums                            
                                
$cnames[$count] = bb_decode($row[0]);
                                
$clink[$count] = 'album_'.$row[1];      
                                
$toplevel[$count]= $rrrow[0];                                                   
                                
$topalblocs[$count] = stripos(bb_decode($row[2]),'<i>') ?  substr(bb_decode($row[2]), stripos(bb_decode($row[2]),'<i>')) : bb_decode($row[2]);              
                        }                                       
                        
$count=$count+1;
                }                                                               
          }
          
          
// Do the link from each category (albums not implemented yet)
          
$sql "SELECT cid,Link_txt FROM {$CONFIG['TABLE_CATEGORIES']} WHERE 1";
          
$link_result db_query($sql);
          while (
$row mysql_fetch_array($link_resultMYSQL_NUM)) {
                        
$lnk_txt[$row[0]] .= trim($row[1]);             
          }
          
          
array_multisort($cnames,$clink,$toplevel,$topalblocs);  
          
$all "<?php \r\n";
          
$all .= '$cnames = ' var_export($cnamestrue) . "; \r\n";
          
$all .= '$clink = ' var_export($clinktrue) . "; \r\n";
          
$all .= '$snames = ' var_export($snamestrue) . "; \r\n";
          
$all .= '$slink = ' var_export($slinktrue) . "; \r\n";
          
$all .= '$toplevel = ' var_export($topleveltrue) . "; \r\n";
          
$all .= '$topalblocs = ' var_export($topalblocstrue) . "; \r\n";
          
$all .= '$salblocs = ' var_export($salblocstrue) . "; \r\n";
          
$all .= '$clink_txt = ' var_export($lnk_txttrue) . "; \r\n";
          
$all .= '?>
';
   
          $outfile = 'include/album_structure_'.$lang_code.'.php';     
    $handle = fopen($outfile,"w");
    fwrite($handle,$all);
    if (fclose($handle)) echo 'Language: '.$lang_code.' completed Successfully!' . "\r\n";             
  } // end of loop through languages
}


Now this last function is very specific for the particular album structure I have so it looks really messy. But I hope you can modify it for your purposes. If your structure is more straightforward, you might be able to get away with just 1 or 2 mysql queries. Hope this helps.





onr

Quote from: GauGau on March 14, 2007, 07:21:07 AM
The page you refered to is hacked beyond recognition (with the "Powered by Coppermine" tag removed), but basically, it is running the outdated cpg1.3.3, which goes unsupported. The owner of the site probably applied the hack himself and did not publish it. I don't think a hack like the one you have posted has been published (yet). Bottom line: I have no idea where to get this hack from.

P.S.: Yes it is true I removed the Coppermine tag because the page now contains basically as much code from Coppermine as from myself but of course Coppermine is a great project and I do acknowledge that the page was developed from a Coppermine basis (see the page http://www.chocolate-fish.net/about.html).

Joachim Müller

Quote from: onr on October 05, 2007, 12:22:24 AM
Yes it is true I removed the Coppermine tag because the page now contains basically as much code from Coppermine as from myself
That's complete and utter nonsense: first of all, Coppermine contains tens of thousands of lines of code that equals thousands of hours of coding. You definitely can't have added as much code into your copy unless you're superhuman. Secondly, it doesn't matter how much work your put into modifying coppermine's core code: coppermine is being released under GNU GPL, which basically means that no matter how much you modify it, it will still be under the GNU GPL license. Coppermine is being released with a license add-on that is legal in terms of the GNU GPL that says you mustn't remove the tag no matter what. Read up http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#copyright_additional_preservation
We welcome your readiness to share your customization, however it is not acceptible that you removed the "Powered by Coppermine" tag both in legal as well as in ethical terms. Restore it! It's little to ask in my opinion.

onr

Quote from: GauGau on October 05, 2007, 07:51:56 AM
That's complete and utter nonsense
Hmm ... you don't know how much work I have put into this site so you shouldn't say things like this. Just the one function that I mention above (and only a small part of it is posted here) contains 500 lines of code and was written in 1 day. So considering that I have worked on this site for over 3 years now, you can probably imagine that there are many thousands of lines of new code and I can tell you that there is little left of the original 1.3 version of Coppermine. Credit is given where it is due (i.e. where I talk about the development of the site I acknowledge and link to Coppermine, see above) but if I placed a credit link to Coppermine on every single page of the over 4000 pages I have, then I would also have to put a link to php.net for everything I learned from their manuals or for every "for loop" and "if condition" that I used (same goes for MYSQL and javascript). Don't get me wrong, I really think it is a good project that you have and I would recommend it to anyone but considering the amount of work I put into this myself it would seem odd to have your name appear on every single page. This would be like writing a book and on every single page of the book you would put a complete reference list of all your sources. You don't do that because it would be silly so instead you put your sources at the end of the book into a reference list or bibliography. People progress and so they use what other people have done and build on it to create something new and better or just something different. On the web things are a bit different cause everything is built on source code which can be copied and modified but how do you patent an "if condition" or a "for loop"? People can look at the source code of any webpage and get ideas from there and use them for their own purposes. That's the good thing about the web and that's how it should be because why should you invent the wheel a second time?

Joachim Müller

That's still nonsense. Removing the tag is illegal. If you don't agree to the license and terms coppermine comes with, you shouldn't have started using it in the first place. PHP.net and the other projects you mention don't require to display such a tag, but coppermine does. Simple as that. Restore it.

onr

Please feel free to delete my account from this forum since my contributions seem to rank in quality between "nonsense" and "complete and utter nonsense". All the best.

Joachim Müller

Your contribution is fine. The missing tag and the reasons you give for not displaying the tag are nonsense.