Alpha Anchors for thumbnails.php page Alpha Anchors for thumbnails.php page
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Alpha Anchors for thumbnails.php page

Started by MarianneC, August 28, 2008, 05:25:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MarianneC

I was thinking that someone else might have asked about this along the way, but I didn't turn up anything in a search of the board.

We want to be able to easily click from the top of the page directly to listings in a particular alpha section (i.e. listings for all artists who's name start with "S".)

We had an old version of CPG (version 1.2) where this was implemented.  It only works for IE, not firefox, but we'd settle for IE.  You can see what I mean here:

http://www.useaboston.com/imagegallery/thumbnails.php?album=3&page=1&sort=na

I tried looking at the old code to see if I could move it to the current version.  There are several changes in functions.inc.php that seem like they are in a section of the code that is pretty constant, and I just dropped them in.  The one piece of code that I have not been able to find the right place for is the chunk that specifically tells CPG to write the anchor tag into the web page. 

That chunk of code used to be in their old theme.php -- back when theme.php had much more php in it and less html.

This is the old code chunk, and it was in the function theme_display_thumbnails section of theme.php.


                // New - ANCHORS

                 if(strlen($thumb['anchor']) > 0)
                 {
                  echo '<a name="' . $thumb['anchor'] . '"></a>';
                 }


If someone is interested, here is the chunk of existing and marked new code that I have added in to functions.inc.php:


       $i = 0;


        if (count($pic_data) > 0) {

// New - JRS
$curr_char = '1';

                foreach ($pic_data as $key => $row) {


                        $i++;



// New - JRS /////////////////////////
$anchor_name = "";
$first_letter = strtoupper(substr($row['filename'],0,1));
if($first_letter != $curr_char)
{
$anchor_name = $first_letter;
$curr_char = $first_letter;
}
/////////////////////////////////////////


                        $pic_title =$lang_display_thumbnails['filename'].$row['filename']."\n".


                                $lang_display_thumbnails['filesize'].($row['filesize'] >> 10).$lang_byte_units[1]."\n".


                                $lang_display_thumbnails['dimensions'].$row['pwidth']."x".$row['pheight']."\n".


                                $lang_display_thumbnails['date_added'].localised_date($row['ctime'], $album_date_fmt);



                        $pic_url =  get_pic_url($row, 'thumb');


                        if (!is_image($row['filename'])) {


                                $image_info = getimagesize(urldecode($pic_url));


                                $row['pwidth'] = $image_info[0];


                                $row['pheight'] = $image_info[1];


                        }





                        $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']);





                        $thumb_list[$i]['pos'] = $key < 0 ? $key : $i - 1 + $lower_limit;


                        $thumb_list[$i]['pid'] = $row['pid'];;


                        $thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"$pic_title\"/>";


                        $thumb_list[$i]['caption'] = bb_decode($row['caption_text']);


                        $thumb_list[$i]['admin_menu'] = '';


                        $thumb_list[$i]['aid'] = $row['aid'];

                       // New - JRS //
                        $thumb_list[$i]['anchor'] = $anchor_name;
                        /////////////////////////////////////////


                }


                theme_display_thumbnails($thumb_list, $thumb_count, $album_name, $album, $cat, $page, $total_pages, is_numeric($album), $display_tabs);


        } else {


                theme_no_img_to_display($album_name);


        }


}



And, of course, the html for all the anchor tags is added to theme.php in $template_thumb_view_title_row


Thank you for your help in solving where the last chunk of code (I hope!) needs to go.

Marianne