Advanced search  

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]

Pages: [1]   Go Down

Author Topic: Customizing Search results  (Read 4409 times)

0 Members and 1 Guest are viewing this topic.

biellebrunner

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 42
Customizing Search results
« on: September 03, 2016, 10:19:07 am »

How can I edit the way the search results are displayed? I looked into theme.php on /sample, but I couldn't find anything specific for search results, and I had no idea which other section it could be.
Thanks.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15759
Re: Customizing Search results
« Reply #1 on: September 06, 2016, 09:07:41 am »

Do you want to edit the actual results or just the appearance / layout?
Logged

biellebrunner

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 42
Re: Customizing Search results
« Reply #2 on: September 14, 2016, 09:05:59 pm »

Just the appearance. Right now, the title and thumbnail of each album result are display each in a different table row. I'd like for them to be in someway similar to how albums are regularly displayed on the gallery.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15759
Re: Customizing Search results
« Reply #3 on: September 16, 2016, 02:09:40 pm »

Open include/search.inc.php, find
Code: [Select]
                        starttable('100%', $lang_meta_album_names['album_search'],2);
                        while ($alb = mysql_fetch_assoc($result)) {
                                $thumb_query = "SELECT filepath, filename, url_prefix, pwidth, pheight "
                                        ." FROM `{$CONFIG['TABLE_PICTURES']}` "
                                        ." WHERE (`aid` = '{$alb['aid']}') "
                                        ." AND approved = 'YES' "
                                        ." ORDER BY `pid` DESC";
                                $thumb_result = cpg_db_query($thumb_query);
                                $thumb = mysql_fetch_assoc($thumb_result);
                                // TODO: query above only pulls in last_pid in each album, not correct album thumb as set by user

                                $thumb_url = get_pic_url($thumb, 'thumb');
                                $thumb_size = compute_img_size($thumb['pwidth'], $thumb['pheight'], $CONFIG['alb_list_thumb_size'], true, 'cat_thumb');
                                ?>
                                <tr>
                                  <td colspan="3" height="1" valign="top" class="tableh2">
                                    <span class="alblink"><a href="<?php printf("thumbnails.php?album=%u"$alb['aid']); ?>"><?php echo $alb['title'?></a></span>
                                  </td>
                                </tr>
                                <tr>
                                        <td colspan="3">
                                                <img src="images/spacer.gif" width="1" height="1" border="0" alt="" /><br />
                                        </td>
                                </tr>
                                <tr>
                                  <td>
                                    <a href="<?php printf("thumbnails.php?album=%u"$alb['aid']); ?> ">
                                        <img src="<?php echo $thumb_url?>"  class="image" <?php echo $thumb_size['geom'?> border="0" alt="<?php echo $thumb['filename'?>">
                                    </a>
                                  </td>
                                  <td width="100%" valign=top>
                                    <?php if ($alb['description'] == "") { echo '&nbsp;'; } else { echo $alb['description']; } ?>
                                  </td>
                                </tr>
                                <?php
                        
}
                        
endtable();
                        echo 
'<br/>';
and replace with
Code: [Select]
                        global $template_thumbnail_view;
                        $template_thumbnail_view_tmp = $template_thumbnail_view;
                        $thumb_cell = template_extract_block($template_thumbnail_view_tmp, 'thumb_cell');
                        $empty_cell = template_extract_block($template_thumbnail_view_tmp, 'empty_cell');
                        $row_separator = template_extract_block($template_thumbnail_view_tmp, 'row_separator');
                        $i = 0;
                        $thumbcols = $CONFIG['thumbcols'];
                        $cell_width = ceil(100 / $CONFIG['thumbcols']) . '%';
                        starttable('100%', $lang_meta_album_names['album_search'], $thumbcols);
                        while ($alb = mysql_fetch_assoc($result)) {
                            $thumb_query = "SELECT filepath, filename, url_prefix, pwidth, pheight "
                                    ." FROM `{$CONFIG['TABLE_PICTURES']}` "
                                    ." WHERE (`aid` = '{$alb['aid']}') "
                                    ." AND approved = 'YES' "
                                    ." ORDER BY `pid` DESC";
                            $thumb_result = cpg_db_query($thumb_query);
                            $thumb = mysql_fetch_assoc($thumb_result);
                            // TODO: query above only pulls in last_pid in each album, not correct album thumb as set by user

                            $thumb_url = get_pic_url($thumb, 'thumb');
                            $thumb_size = compute_img_size($thumb['pwidth'], $thumb['pheight'], $CONFIG['thumb_width'], true, 'cat_thumb');

                            $params = array(
                                '{CELL_WIDTH}' => $cell_width,
                                '{LINK_TGT}'   => 'thumbnails.php?album='.$alb['aid'],
                                '{THUMB}'      => '<img src="'.$thumb_url.'" class="image thumbnail" '.$thumb_size['geom'].' border="0" alt="'.$thumb['filename'].'">',
                                '{CAPTION}'    => '<span class="thumb_title thumb_title_title">'.$alb['title'].'</span>',
                                '{ADMIN_MENU}' => '',
                            );
                            echo template_eval($thumb_cell, $params);

                            if ((($i % $thumbcols) == 0) && ($i < mysql_num_rows($result))) {
                                echo $row_separator;
                            }
                            $i++;
                        }
                        for (;($i % $thumbcols); $i++) {
                            echo $empty_cell;
                        }
                        endtable();
                        echo '<br/>';
Logged

biellebrunner

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 42
Re: Customizing Search results
« Reply #4 on: October 25, 2016, 06:17:15 am »

That worked, thanks.
Just one thing: the first result for the albums is on its own table, taking the whole width. (example: http://stanakaticbrasil.com/galeria/thumbnails.php?search=choice&title=on&album_title=on&category_title=on&caption=on&keywords=on&filename=on&album=search&type=OR)
Also, the albums thumbnails aren't the right size or proportion (like the photo results are, for example).
Did I do something wrong?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15759
Re: Customizing Search results
« Reply #5 on: June 30, 2017, 03:46:36 pm »

Sorry for the late reply. Not sure if you have the mod still applied, but currently the search results look like the unmodified results. Please re-apply the mod, so I can have a look what's wrong.
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 20 queries.