ADD "add to favorites" on thumbnail view ADD "add to favorites" on thumbnail view
 

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

ADD "add to favorites" on thumbnail view

Started by radianation, December 16, 2004, 10:15:54 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

radianation

How can I include the "add to favorites" information on the thumbnail view page (and also on the My Favorites display page)? I have modified my English theme file to change the default text to a button with/without a checkbox (looks nice). I'd like to have this show up under the thumbnails view as well so that people can easily add several photos at once from a gallery to their favorites. Thanks!

Hein Traag

Nice one, had not thougt of this myself.

Would indeed speed up adding favourite pictures to MyFavourites if one were able to select the pictures from the thumbnail page.

No clue how to code this but maybe one of the more skilled coders could do his/her magic to this. Imho many galleries can benefit from
a hack or mod to give that option to visitors.

radianation

I'm glad you agree. I also have a hack that I'd like to post that allows for the sorting of favorites and then a special Emailing of the thumbnails (modified E-Card). I use it like a shopping cart of sorts for images. I'll try to find where I need to post them and make it happen.

Joachim Müller

post your modification in the support board that matches your coppermine version, a moderator will move it to the mods/hacks section if applicable.

Joachim

donnoman

I posted a modification to add the "add to favorites" link to the img_nav_bar, adding it elsewhere would be similar.

http://forum.coppermine-gallery.net/index.php?topic=12854.msg58480#msg58480

radianation

I just tried implementing this today and I'm not really sure where I should add the code referenced. Specifically, I can't figure out where to add

                <td align="center" valign="middle" class="navmenu" width="48">
                        {FAVORITE}
                </td>


...

I'm thinking it needs to go somewhere in here?

// HTML template for thumbnails display
$template_thumbnail_view = <<<EOT

<!-- BEGIN header -->
        <tr>
<!-- END header -->
<!-- BEGIN thumb_cell -->
        <td valign="top" class="thumbnails" width ="{CELL_WIDTH}" align="center">
                <table width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                                <td align="center">
                                        <a href="{LINK_TGT}">{THUMB}<br /></a>
                                        {CAPTION}
{FIL_SET_ORDER}
                                        {ADMIN_MENU}
{FAVORITE}
                                </td>
                        </tr>
                </table>
        </td>
<!-- END thumb_cell -->
<!-- BEGIN empty_cell -->
                <td valign="top" class="thumbnails" align="center">&nbsp;</td>
<!-- END empty_cell -->
<!-- BEGIN row_separator -->
        </tr>
        <tr>
<!-- END row_separator -->
<!-- BEGIN footer -->
        </tr>
<!-- END footer -->
<!-- BEGIN tabs -->
        <tr>
                <td colspan="{THUMB_COLS}" style="padding: 0px;">
                        <table width="100%" cellspacing="0" cellpadding="0">
                                <tr>
                                        {TABS}
                                </tr>
                        </table>
                </td>
        </tr>
<!-- END tabs -->
<!-- BEGIN spacer -->
        <img src="images/spacer.gif" width="1" height="17" /><br />
<!-- END spacer -->

EOT;


did I add it in the right spot?

radianation

OK, all that did was add {FAVORITE} under my thumbnails. It's a start.

I suspect I need to add something like into thumbnails.php or another file?

    // Create the add to fav link
    if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
        $info[$lang_picinfo['addFavPhrase']] = "<a href=addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . " >" . $lang_picinfo['addFav'] . '</a>';
    } else {
        $info[$lang_picinfo['addFavPhrase']] = "<a href=addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . " >" . $lang_picinfo['remFav'] . '</a>';
    }



donnoman

I did this with classic, your theme may differ slightly.

thumbnails.php; find:

define('INDEX_PHP', true);


Add after it:

define('DISPLAYIMAGE_PHP', true);     // Favorite MOD (you need access to $lang_picinfo)


include/functions.inc.php; function display_thumbnails; find:

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


add after it:

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


theme.php; $template_thumbnail_view; find:

<!-- BEGIN thumb_cell -->
       <td valign="top" class="thumbnails" width ="{CELL_WIDTH}" align="center">
               <table width="100%" cellpadding="0" cellspacing="0">
                       <tr>
                               <td align="center">
                                       <a href="{LINK_TGT}">{THUMB}<br /></a>
                                       {CAPTION}
                                       {ADMIN_MENU}
                               </td>
                       </tr>
               </table>
       </td>
<!-- END thumb_cell -->


replace with:

<!-- BEGIN thumb_cell -->
       <td valign="top" class="thumbnails" width ="{CELL_WIDTH}" align="center">
               <table width="100%" cellpadding="0" cellspacing="0">
                       <tr>
                               <td align="center">
                                       <a href="{LINK_TGT}">{THUMB}<br /></a>
                                       {CAPTION}
                                       {ADMIN_MENU}
                                       {FAVORITE}
                               </td>
                       </tr>
               </table>
       </td>
<!-- END thumb_cell -->


theme.php; function theme_display_thumbnails; find:

   global $template_thumb_view_title_row,$template_fav_thumb_view_title_row, $lang_thumb_view, $template_tab_display, $template_thumbnail_view;


add after it:

   global $lang_picinfo, $FAVPICS;  // Favorite MOD


theme.php; function theme_display_thumbnails; find:

   foreach($thumb_list as $thumb) {
       $i++;
       if ($mode == 'thumb') {


replace it with:

   foreach($thumb_list as $thumb) {
       $i++;
       // Favorite MOD
       if (!in_array($thumb['pid'], $FAVPICS)) {
           $favorite = "<a href=\"addfav.php?pid=" . $thumb['pid'] . "\">" . $lang_picinfo['addFav'] . '</a>';
       } else {
           $favorite = "<a href=\"addfav.php?pid=" . $thumb['pid'] . "\">" . $lang_picinfo['remFav'] . '</a>';
       }
       // Favorite MOD
       if ($mode == 'thumb') {


theme.php; function theme_display_thumbnails; find:

       if ($mode == 'thumb') {
           if ($aid == 'lastalb') {
               $params = array('{CELL_WIDTH}' => $cell_width,
                   '{LINK_TGT}' => "thumbnails.php?album={$thumb['aid']}",
                   '{THUMB}' => $thumb['image'],
                   '{CAPTION}' => $thumb['caption'],
                   '{ADMIN_MENU}' => $thumb['admin_menu']
                   );
           } else {
               $params = array('{CELL_WIDTH}' => $cell_width,
                   '{LINK_TGT}' => "displayimage.php?album=$aid$cat_link&pos={$thumb['pos']}",
                   '{THUMB}' => $thumb['image'],
                   '{CAPTION}' => $thumb['caption'],
                   '{ADMIN_MENU}' => $thumb['admin_menu']
                   );
           }
       } else {
           $params = array('{CELL_WIDTH}' => $cell_width,
               '{LINK_TGT}' => "index.php?cat={$thumb['cat']}",
               '{THUMB}' => $thumb['image'],
               '{CAPTION}' => $thumb['caption'],
               '{ADMIN_MENU}' => ''
               );
       }


replace it with:

       if ($mode == 'thumb') {
           if ($aid == 'lastalb') {
               $params = array('{CELL_WIDTH}' => $cell_width,
                   '{LINK_TGT}' => "thumbnails.php?album={$thumb['aid']}",
                   '{THUMB}' => $thumb['image'],
                   '{CAPTION}' => $thumb['caption'],
                   '{ADMIN_MENU}' => $thumb['admin_menu'],
                   '{FAVORITE}' => $favorite,       // Favorite MOD
                   );
           } else {
               $params = array('{CELL_WIDTH}' => $cell_width,
                   '{LINK_TGT}' => "displayimage.php?album=$aid$cat_link&pos={$thumb['pos']}",
                   '{THUMB}' => $thumb['image'],
                   '{CAPTION}' => $thumb['caption'],
                   '{ADMIN_MENU}' => $thumb['admin_menu'],
                   '{FAVORITE}' => $favorite,       // Favorite MOD
                   );
           }
       } else {
           $params = array('{CELL_WIDTH}' => $cell_width,
               '{LINK_TGT}' => "index.php?cat={$thumb['cat']}",
               '{THUMB}' => $thumb['image'],
               '{CAPTION}' => $thumb['caption'],
               '{ADMIN_MENU}' => '',
               '{FAVORITE}' => $favorite,       // Favorite MOD
               );
       }


Hope that helps.

FYI (Radio buttons wont work here, this does one image at a time.)

I think you could do a form by placing it in the header and footers of $template_thumbnail_view
but then your going to have to work passing that info and parsing it with addfav.php.

You could also probably manipulate referrer with addfav to send you back to the same album.

Thats currently a little larger project than I want to take on for 1.3x.

If you love this functionality perhaps some folks can put it in a feature request, perhaps I'd do it for a future version if there were enough interest.

radianation

Thank you for the speedy reply. I'll have to wait until the AM to test it, but as soon as I do I'll post my results. Your help is greatly appreciated.

ScenicNH

Will this code work in 1.3x. or just classic? To add "add to favorites" under the thumbnail view

Joachim Müller

"1.3.x" is the coppermine version, "classic" is the theme used. Those terms are not antonyms nor synonyms. If you drive a "Ford Escort" in red, a question like "do these tires fit on an escort or a red car?" simply doesn't apply.

As donnoman suggested: the code he mentioned will work with slight customizations for any theme. As favorites didn't exist in older versions than cpg1.3.0 and there's no support yet for cpg1.4.x, your question on the coppermine version simply doesn't apply.

Joachim

ScenicNH


I am very sorry for the stupid question........ I thought "Classic" was a older verison of Coppermine. I guess if I was a project manager of coppermine  I would know this.
Kinda like did you see that classic red escort driving down the road. The classic escort would be any older version on the escort.
A simple mistake on my part......Very Sorry.........

http://forum.coppermine-gallery.net/index.php?topic=15569.msg72491#msg72491
ScenicNH

d1zz13

Don't really have much to say on this topic, I think that "add to favorites" option from the thumbnail page is superb.

I just wanted to say that I love the comparisons being used  :D

QuoteI thought "Classic" was a older verison of Coppermine. I guess if I was a project manager of coppermine  I would know this.
Kinda like did you see that classic red escort driving down the road. The classic escort would be any older version on the escort.

radianation

Yes, this simple mod can really open doors with creative programmers for turning coppermine into a makeshift shopping cart, even though I think there is a mod specifically for this already.

JoeBen

Hi donnoman  -  Thank you very much for posting a solution to this.  It works awesome.  I am a newbie and am wondering how I can make it so that when a user clicks on add to favorites in the thumbnail view the view stays in the thumbnail view instead of switching to the display image view.  I think I have to change this line but I do not know what to change it to.

$location = "displayimage.php?pos=" . (- $pic);

Thank you very much,

JoeBen

JoeBen

Two more things I forgot to mention:

1.  You can go to my site at www.vientodelmar.com to see what I am talking about.  If you are in a thumbnail view and you click on add to download queue it will take you to the detail view for that image.  I would like it to stay in the thumbnail view.

2.  I think I need to change the following line in addfav.php but I am not sure if that is right or how to change it.

$location = "displayimage.php?pos=" . (- $pic);

Thank you!

radianation

$location = "thumbnails.php?album=" . (- $album);

I changed it to this, but I'm not getting the album variable passed. Can somebody assist?

radianation

#17
theme.php

        // Favorite MOD
        if (!in_array($thumb['pid'], $FAVPICS)) {
            $favorite = "<a href=\"addfav.php?pid=" . $thumb['pid'] . ";album=" . $thumb['aid'] . "\">" . $lang_picinfo['addFav'] . '</a>';
        } else {
            $favorite = "<a href=\"addfav.php?pid=" . $thumb['pid'] . ";album=" . $thumb['aid'] . "\">" . $lang_picinfo['remFav'] . '</a>';
        }


Would I need to change this modification to include the passing of the $album variable? Then I can refer to it in the addfav.php file as I indicated above.

radianation

then you need to add this to your addfav.php

$album = (int)$HTTP_GET_VARS['aid'];