Advanced search  

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

Pages: [1]   Go Down

Author Topic: [Solved]: Add to favorites button in navbar (almost there)  (Read 7607 times)

0 Members and 1 Guest are viewing this topic.

aldog

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 29
[Solved]: Add to favorites button in navbar (almost there)
« on: April 30, 2008, 02:10:00 am »

With help from these topics
http://forum.coppermine-gallery.net/index.php/topic,26315.0.html
http://forum.coppermine-gallery.net/index.php/topic,12854.msg58480.html
http://forum.coppermine-gallery.net/index.php/topic,50236.msg241952.html

I've managed to get very close to having a favorites button in the navigation bar. But now I guess I've hit a wall and can't figure out how to get over it.

I'm using stramm's modpack with the oranje theme, but my navbar is mainly from the eyeball theme. I'm assuming that given that, my thread should go in this forum, if it should go in stramm's forum I apologize and would ask that a mod move it.

What I've Done:



In displayimage.php
after
Code: [Select]
// Display picture information
function html_picinfo()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR, $REFERER;
    global $album, $lang_picinfo, $lang_display_image_php, $lang_byte_units, $lastup_date_fmt;
I added
Code: [Select]
    global $FAVPICS ;//ajout pour icone favorits




In theme.php
After this
Code: [Select]
<!-- BEGIN ecard_button -->
                <td align="center" valign="middle" class="navmenu" width="48">
                        <a href="{ECARD_TGT}" class="navmenu_pic" title="{ECARD_TITLE}"><img src="{LOCATION}images/newnav/ecard.gif"  border="0" align="middle" alt="{ECARD_TITLE}" /></a>
                </td>
<!-- END ecard_button -->
I've added this code
Code: [Select]
<!-- DEBUT lien vers les favorits (ajout FRANTZ) -->
                <td align="center" valign="middle" class="navmenu" width="48">
                        <a href="{FAV_TGT}" class="navmenu_pic" title="{FAV_TITLE}"><img src="{LOCATION}images/newnav/fav.gif" border="0" align="middle" alt="{FAV_TITLE}" /></a>
                </td>
<!-- FIN Lien favorits (ajout FRANTZ) -->


At the end of the theme.php, before ?> I put this
Code: [Select]
function theme_html_img_nav_menu()
{
    global $CONFIG, $CURRENT_PIC_DATA, $meta_nav, $THEME_DIR ; //$PHP_SELF,
    global $album, $cat, $pos, $pic_count, $lang_img_nav_bar, $lang_text_dir, $template_img_navbar;
    global $lang_picinfo, $FAVPICS ;//ajout pour icone favorits

    $cat_link = is_numeric($album) ? '' : '&amp;cat=' . $cat;
        $uid_link = is_numeric($_GET['uid']) ? '&amp;uid=' . $_GET['uid'] : '';

    $human_pos = $pos + 1;
    $page = ceil(($pos + 1) / ($CONFIG['thumbrows'] * $CONFIG['thumbcols']));
    $pid = $CURRENT_PIC_DATA['pid'];

    $start = 0;
        $start_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$start";
        $start_title = $lang_img_nav_bar['go_album_start'];
        $meta_nav .= "<link rel=\"start\" href=\"$start_tgt\" title=\"$start_title\" />
        ";
        $end = $pic_count - 1;
        $end_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$end";
        $end_title = $lang_img_nav_bar['go_album_end'];
        $meta_nav .= "<link rel=\"last\" href=\"$end_tgt\" title=\"$end_title\" />
        ";

    if ($pos > 0) {
        $prev = $pos - 1;
        $prev_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$prev$uid_link";
        $prev_title = $lang_img_nav_bar['prev_title'];
                                $meta_nav .= "<link rel=\"prev\" href=\"$prev_tgt\" title=\"$prev_title\" />
                                ";
    } else {
        $prev_tgt = "javascript:;";
        $prev_title = "";
    }

    if ($pos < ($pic_count -1)) {
        $next = $pos + 1;
        $next_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$next$uid_link";
        $next_title = $lang_img_nav_bar['next_title'];
                                $meta_nav .= "<link rel=\"next\" href=\"$next_tgt\" title=\"$next_title\"/>
                                ";
    } else {
        $next_tgt = "javascript:;";
        $next_title = "";
    }

    if (USER_CAN_SEND_ECARDS) {
        $ecard_tgt = "ecard.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos";
        $ecard_title = $lang_img_nav_bar['ecard_title'];
    } else {
        template_extract_block($template_img_navbar, 'ecard_button'); // added to remove button if cannot send ecard
        /*$ecard_tgt = "javascript:alert('" . addslashes($lang_img_nav_bar['ecard_disabled_msg']) . "');";
        $ecard_title = $lang_img_nav_bar['ecard_disabled'];*/
    }

                //report to moderator buttons
    if (($CONFIG['report_post']==1) && (USER_CAN_SEND_ECARDS)) {
        $report_tgt = "report_file.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos";
    } else { // remove button if report toggle is off
        template_extract_block($template_img_navbar, 'report_file_button');

    }

                    $thumb_tgt = "thumbnails.php?album=$album$cat_link&amp;page=$page$uid_link";
        $meta_nav .= "<link rel=\"up\" href=\"$thumb_tgt\" title=\"".$lang_img_nav_bar['thumb_title']."\"/>
        ";

    $slideshow_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link$uid_link&amp;pid=$pid&amp;slideshow=".$CONFIG['slideshow_interval'];

    $pic_pos = sprintf($lang_img_nav_bar['pic_pos'], $human_pos, $pic_count);

    if (defined('THEME_HAS_NAVBAR_GRAPHICS')) {
            $location= $THEME_DIR;
        } else {
            $location= '';
        }
//ajout pour lien vers favorits (Frantz)
// Create the add to fav link
       
    if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
        $fav_tgt  = "addfav.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos";
        $fav_title = $lang_picinfo['addFav'];
    } else {
        $fav_tgt = "addfav.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos";
        $fav_title = $lang_picinfo['remFav'];
    }
//fin ajout
    $params = array('{THUMB_TGT}' => $thumb_tgt,
        '{THUMB_TITLE}' => $lang_img_nav_bar['thumb_title'],
        '{PIC_INFO_TITLE}' => $lang_img_nav_bar['pic_info_title'],
        '{SLIDESHOW_TGT}' => $slideshow_tgt,
        '{SLIDESHOW_TITLE}' => $lang_img_nav_bar['slideshow_title'],
        '{PIC_POS}' => $pic_pos,
        '{ECARD_TGT}' => $ecard_tgt,
        '{ECARD_TITLE}' => $ecard_title,
        '{PREV_TGT}' => $prev_tgt,
        '{PREV_TITLE}' => $prev_title,
        '{NEXT_TGT}' => $next_tgt,
        '{NEXT_TITLE}' => $next_title,
        '{PREV_IMAGE}' => ($lang_text_dir=='ltr') ? 'prev' : 'next',
        '{NEXT_IMAGE}' => ($lang_text_dir=='ltr') ? 'next' : 'prev',
        '{REPORT_TGT}' => $report_tgt,
        '{REPORT_TITLE}' => $lang_img_nav_bar['report_title'],
        '{LOCATION}' => $location,
        '{FAV_TGT}' => $fav_tgt,//ajout Frantz
      '{FAV_TITLE}' => $fav_title,//ajout Frantz
        );

    return template_eval($template_img_navbar, $params);
}




My Problem:
After adding the previous snippet to the end of my theme.php, the favorites button works (woohoo) but the picture title, the owner name, and the owner ID do not anymore, they now navigate to http://ad6storieshigh.com/gallery/{OWNER_NAME} respectively

So I'm guessing the solution (even if it's not pretty) would be to remove everything from the "function theme_html_img_nav_menu()" that I don't need, I've tried to do this but haven't been able to accomplish it yet, either I don't remove enough, or I remove too much

My Gallery http://ad6storieshigh.com/gallery/displayimage.php?pos=-642
my theme.php is attached as well.

« Last Edit: April 30, 2008, 07:03:29 pm by Nibbler »
Logged

Nibbler

  • Guest
Re: Add to favorites button in navbar (almost there)
« Reply #1 on: April 30, 2008, 10:21:14 am »

You need to copy in the modpack's version of theme_html_img_nav_menu() not the the stock version. I think you need to copy from include/themes.inc.php and then apply your modifications to the new copy.
Logged

Stramm

  • Moderator
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Add to favorites button in navbar (almost there)
« Reply #2 on: April 30, 2008, 10:27:54 am »

You need to copy in the modpack's version of theme_html_img_nav_menu() not the the stock version. I think you need to copy from include/themes.inc.php and then apply your modifications to the new copy.

Yes, thanks Nibbler!

aldog

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 29
Re: Add to favorites button in navbar (almost there)
« Reply #3 on: April 30, 2008, 06:41:04 pm »

aaahhh yes perfect! my favorites button is working great now!

http://ad6storieshigh.com/gallery/displayimage.php?pos=-476


And just to help anyone out that wants the same...a full explanation.
(I'm using stramm's modpack, oranje theme, but my navbar is taken from eyeball and modified slightly)

1st - Add a image fav.gif into your themes/images/ folder (mine is located in themes/images/newnav/ just so I can edit those files and leave stramm's alone)

2nd - In themes/yourtheme/theme.php
AFTER
Code: [Select]
<!-- BEGIN ecard_button -->
                <td align="center" valign="middle" class="navmenu" width="48">
                        <a href="{ECARD_TGT}" class="navmenu_pic" title="{ECARD_TITLE}"><img src="{LOCATION}images/ecard.gif"  border="0" align="middle" alt="{ECARD_TITLE}" /></a>
                </td>
<!-- END ecard_button -->

ADD
Code: [Select]
<!-- DEBUT lien vers les favorits (ajout FRANTZ) -->
                <td align="center" valign="middle" class="navmenu" width="48">
                        <a href="{FAV_TGT}" class="navmenu_pic" title="{FAV_TITLE}"><img src="{LOCATION}images/fav.gif" border="0" align="middle" alt="{FAV_TITLE}" /></a>
                </td>
<!-- FIN Lien favorits (ajout FRANTZ) -->

3rd - Open include/themes.inc.php (this code might already be in your themes/yourtheme/theme.php, if so skip to step 4)
Copy the whole function..
Code: [Select]
function theme_html_img_nav_menu()Paste it into THEMES.PHP right before
Code: [Select]
?>Close themes.inc.php, don't edit it or save changes to it.

4th - In function theme_html_img_nav_menu()
After
Code: [Select]
    global $album, $cat, $pos, $pic_count, $lang_img_nav_bar, $lang_text_dir, $template_img_navbar;Add
Code: [Select]
    global $lang_picinfo, $FAVPICS ;//ajout pour icone favorits
After
Code: [Select]
$CONFIG['slideshow_interval'];

    $pic_pos = sprintf($lang_img_nav_bar['pic_pos'], $human_pos, $pic_count);

    if (defined('THEME_HAS_NAVBAR_GRAPHICS')) {
            $location= $THEME_DIR;
        } else {
            $location= '';
        }
Add
Code: [Select]
//ajout pour lien vers favorits (Frantz)
// Create the add to fav link
       
    if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
        $fav_tgt  = "addfav.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos";
        $fav_title = $lang_picinfo['addFav'];
    } else {
        $fav_tgt = "addfav.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos";
        $fav_title = $lang_picinfo['remFav'];
    }
//fin ajout
close theme.php (save of course)


5th - In (galleryroot)/displayimage.php
AFTER

Code: [Select]
// Display picture information
function html_picinfo()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR, $REFERER;
    global $album, $lang_picinfo, $lang_display_image_php, $lang_byte_units, $lastup_date_fmt;
ADD
Code: [Select]
    global $FAVPICS ;//ajout pour icone favorits

Thanks Nibbler and stramm.
all credit goes to the people in the threads mentioned in my first post


Logged

dwo

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 143
Re: [Solved]: Add to favorites button in navbar (almost there)
« Reply #4 on: June 04, 2008, 03:24:34 pm »

Thanks. Works well.

But you missed to tell to add the following code.

'{FAV_TGT}' => $fav_tgt,//ajout Frantz
'{FAV_TITLE}' => $fav_title,//ajout Frantz

See above your first post.

regards, Dietmar
Logged

aldog

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 29
Re: [Solved]: Add to favorites button in navbar (almost there)
« Reply #5 on: July 05, 2008, 03:38:03 am »

I can't tell by my posts if that bit of code is needed. Did you try it without that? if so what was the result/error?
I'll edit it into my post if it is needed, just let me know
Logged

Ravenswd

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 3
    • Safe Comment
Re: [Solved]: Add to favorites button in navbar (almost there)
« Reply #6 on: August 08, 2008, 02:30:23 pm »

I can't tell by my posts if that bit of code is needed. Did you try it without that? if so what was the result/error?
I'll edit it into my post if it is needed, just let me know

This bit:
Code: [Select]
        '{FAV_TGT}' => $fav_tgt,//ajout Frantz
        '{FAV_TITLE}' => $fav_title,//ajout Frantz

needs to be added to function theme_html_img_nav_menu right before:

Code: [Select]
        );

    return template_eval($template_img_navbar, $params);
}

Otherwise, instead of "Add to favorites", you just get "{FAV_TITLE}" and a broken link.

Also, (and I apologize if I'm stating the obvious, but being a newbie it took me a little time to figure out), before doing any of this you need to copy the section

Code: [Select]
// HTML template for the image navigation bar
$template_img_navbar = <<<EOT
(( etc etc copy the whole thing up to EOT ))
EOT;

from themes.inc.php to theme.php .

Thanks for this excellent mod.  ;D
Logged
Hey, you kids! Get off my lawn!
BitmapWorld.com
Pages: [1]   Go Up
 

Page created in 0.027 seconds with 20 queries.