Add to Favorites as Text and button Add to Favorites as Text and button
 

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

Add to Favorites as Text and button

Started by Walkinman, January 11, 2006, 09:37:12 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Walkinman

hey folks,

I would like to have the 'add to favorites' (which I've called "Lightbox")  link show as the text link it currently does under "file Info" at the bottom of the image page, but I would also like to replace the 'slide show' button in the Image Nav Bar with an 'add to lightbox" button. Is this possible? If so, can I set it up as a roll over button?

Here's a link to my site:

http://www.skolaiimages.com/stock/index.php

Thanks so much for all your help.

Cheers

Carl

Walkinman

Hey folks,

I've looked at a number of threads on this, but I can't find one that fits my setp.

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

Is close, but in the displayimage.php I can't find the

function html_img_nav_menu;

that Donnoman says to alter.

I'm using Water-Drop, but I wouldn't think this would matter. Maybe it's the new version of cpg.

Any input would be very helpful.

Thank you

Cheers

Carl

Walkinman

Hey Folks

Here's a couple of things I've tried, and neither seem to work. Perhaps someone here can tell me what I'm doing wrong:

I tried this:

// 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'] . '" ><img src="http://www.skolaiimages.com/buttons/addlight.jpg" width="100" height="100" alt="" title="'. $lang_picinfo['addFav'] . '" /></a>';
    } else {
        $info[$lang_picinfo['addFavPhrase']] = '<a href=addfav.php?pid="' . $CURRENT_PIC_DATA['pid'] . '" ><img src="http://www.skolaiimages.com/buttons/remlight.jpg" width="100" height="100" alt="" title="'. $lang_picinfo['remFav'] . '" /></a>';
    }

    return theme_html_picinfo($info);
}


and got this:

Parse error: parse error, unexpected T_STRING in /home/skola2/public_html/stock/displayimage.php on line 173


and I tried this:

    // Create the add to fav link
    if (USER_ID){
    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>';
    }
    }

I also tried (to disallow non registered user from using the lightbox) got this:

Parse error: parse error, unexpected T_STRING in /home/skola2/public_html/stock/displayimage.php on line 111

I don't recall what line the first error was on, but I'm fairly sure the line 11 error was on the line:

  if (USER_ID){

Is it likely something I'm doing wrong, or might there be something elsewhere in the code that's not right?

Thanks folks.

Cheers

Carl

Tranz

Are you editing with a WYSIWYG editor? Try using a plain text editor like notepad or wordpad (and save in text-only).

Walkinman

Hello TranzNDance,

Yes, I'm using Dreamweaver. I never thought that might be part of the problem. I'll give it a whirl and report back.

Thanks for the help.

Cheers

Carl

Walkinman

#5
Hello TranzNDance,

Nope. I opene dthe file in text Editor, pasted this

// 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'] . '" ><img src="http://www.skolaiimages.com/buttons/addlight.jpg" width="100" height="25" alt="" title="'. $lang_picinfo['addFav'] . '" /></a>';
    } else {
        $info[$lang_picinfo['addFavPhrase']] = '<a href=addfav.php?pid="' . $CURRENT_PIC_DATA['pid'] . '" ><img src="http://www.skolaiimages.com/buttons/remlight.jpg" width="100" height="25" alt="" title="'. $lang_picinfo['remFav'] . '" /></a>';
    }

    return theme_html_picinfo($info);
}

and got the same blank white page with a 'parse error'.

Any other ideas?

edit:

OK .. I removed this:

  return theme_html_picinfo($info);
}

and the lightbox button appears. So far so good. But when i click it, I get this error:

The selected album/file does not exist !

File: /home/skola2/public_html/stock/include/functions.inc.php - Line: 1308

Any ideas on what might that be?

Thanks again.

Cheers

Carl

Joachim Müller

it's hard to say anything without seing what you did and where you pasted what. Please use the [ c o d e ] tags on this board (without the spaces) to make your postings more readable, your code blocks then look like this: // 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'] . '" ><img src="http://www.skolaiimages.com/buttons/addlight.jpg" width="100" height="25" alt="" title="'. $lang_picinfo['addFav'] . '" /></a>';
    } else {
        $info[$lang_picinfo['addFavPhrase']] = '<a href=addfav.php?pid="' . $CURRENT_PIC_DATA['pid'] . '" ><img src="http://www.skolaiimages.com/buttons/remlight.jpg" width="100" height="25" alt="" title="'. $lang_picinfo['remFav'] . '" /></a>';
    }

    return theme_html_picinfo($info);
}

You might want to attach your file (renaming the extension to txt) to your postings as well.

Walkinman

Hey GauGau,

Thanks. I didn't know that about the [ c o d e } thing .. I'll try it, thank you. Sorry about that.

I'll try to attach the displayimage.txt file as you suggest.

Thank you.

Cheers

Carl

Joachim Müller

you're using cpg1.4.2 - upgrade to cpg1.4.3

Walkinman

Hey GauGau,

Really? I thought I did upgrade recently .. you told me that on another thread, and I did it, and it fixed the problem. I must have saved the wrong file somewhere or something.

I'll try to upgrade again and see if that fixes it. I'll be back in the morning.

Thank you.

Cheers

Carl

Walkinman

Hey GauGau,

I've gone through the upgrade, but expect I made a few errors.

Anyway, I get the same reply when I click the "add to Lightbox" button:

The selected album/file does not exist !

File: /home/skola2/public_html/stock/include/functions.inc.php - Line: 1308

Again, I'll attach the displayimage.txt file. And here's a link to my site:

www.skolaiimages.com/stock/index.php

Thank you.

Cheers

Carl

Walkinman

Hey folks,

If anyone has any ideas that might help, I'd really appreciate it. I have the "Add To Lightbox" button up, but keep getting the same error referenced above. Obviously something needs tweaking.

Thank you.

Cheers

Carl

qseb

Credits to Donnoman (check the link on top of this thread) and to walkinman : I've just finnished the hack to display a button in navigation bar to manage favorites. The only file to be changed is themes.inc.php.
The button addfav.gif has to be placed in the general image folder of cpg.

Go!

1/after
<!-- 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>

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


2/ replace
    global $CONFIG, $CURRENT_PIC_DATA, $meta_nav, $THEME_DIR ; //$PHP_SELF,
with
global $CONFIG, $CURRENT_PIC_DATA, $meta_nav, $THEME_DIR, $FAVPICS ; //$PHP_SELF,


3/ after
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'];*/
    }

add
if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
        $favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . ' ><img src="images/addfav.gif" align="middle" border="0" alt="" title="'. $lang_picinfo['addFav'] . '" /></a>';
    } else {
        $favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . ' ><img src="images/addfav.gif" align="middle" border="0" alt="" title="'. $lang_picinfo['remFav'] . '" /></a>';
    }


4/ after
'{ECARD_TGT}' => $ecard_tgt,
'{ECARD_TITLE}' => $ecard_title,

add
'{FAVORITE}' => $favorite,


Walkinman

Hey gseb,

Thank you for that. That worked great. I have 2 questions, and I know there's a one question per rule policy, but these 2 both apply to this same modification. If you or anyone can help out, it'd be really appreciated.

1* is there a way to make that button/option only appear for Users who are registered and logged in?

2* is there a way to make those 'add to lightbox" buttons act as 'rollover' buttons when I mouse over them?

Again, I really appreciate the help. Thanks.

Cheers

Carl

qseb

#14
1* after if ($which == 'sys_menu' ) {
    if (USER_ID) {
        template_extract_block($template_sys_menu, 'login');
    } else {
        template_extract_block($template_sys_menu, 'logout');
        template_extract_block($template_sys_menu, 'my_profile');

add template_extract_block($template_sub_menu, 'favpics');

and check that your theme.php in template dir has <!-- BEGIN favpics --> and <!-- END favpics --> around <a href="{FAV_TGT}" title="{FAV_LNK}">{FAV_LNK}</a>

2* htlm code:
<a href="home.html"
onMouseOver="document.images[0].src='fav.gif'"
onMouseOut="document.images[0].src='fav2.gif'">
<img src="fav.gif" width=192 height=47 alt="" border="0">
</a>

but to insert this in the 3/ code  ???

Walkinman

Hey Gseb,

Thank you. I got the first step of 1* finished (I think), but I get this error on the image pages now:

Template error
Failed to find block 'favpics'(#(<!-- BEGIN favpics -->)(.*?)(<!-- END favpics -->)#s) in :

            <!-- BEGIN custom_link -->
        <a class="sysmenu" href="{CUSTOM_LNK_TGT}" title="{CUSTOM_LNK_TITLE}">{CUSTOM_LNK_LNK}</a> &nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;
  <!-- END custom_link -->  <!-- BEGIN My Lightbox -->
        <a class="sysmenu" href="{FAV_TGT}" title="{My Lightbox}">{FAV_LNK}</a> &nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;
  <!-- END My Lightbox -->  <!-- BEGIN search -->
        <a class="sysmenu" href="{SEARCH_TGT}" title="{SEARCH_TITLE}">{SEARCH_LNK}</a>
  <!-- END search -->



This is obviously related to Step 2 .. but I can't find the tag you reference:

<a href="{FAV_TGT}" title="{FAV_LNK}">{FAV_LNK}</a>

it's in the theme.php file you said?

I haven't tried to tackle the Mouse Over tag yet .. I doubt I'm able to manage that one.  ;)

If you (or anyone else) could help me find the tag you mentioned for the first question I'd really appreciate it.

Thanks.

Cheers

Carl

Paver

The "Template error - Failed to find block" is a common error mentioned in multiple threads in this forum.  Please read some of the other discussion to learn more about it.  How to deal with template blocks is very clearly explained in at least 2 other threads.

The basic knowledge you absolutely need to know about themes is that the sample theme includes all the code you can include in your custom theme.  Go into the sample/theme.php and copy the code you want.  Only copy the code you want, you don't have to copy it all - it's meant to be a central place to look for theme customizations.

Walkinman

Hey Paver,

Thank you. I've read over the upgrade section in the docs, but I'm not sure what I need to add. I'm still lost.

I understand I need to copy code from the sample/theme/php file, but I can't find anything in there which has this:

<a href="{FAV_TGT}" title="{FAV_LNK}">{FAV_LNK}</a>

Item # 10 in the upgrade docs says  top copy a large portion of code from the old.theme.php, but those codes aren't in my old theme.php. I've attached a copy of my theme as a text file here. I'm not sure exactly what mod I need to make, or where to make it. I'll also switch my site back to debug mode.

Thank you.

Cheers

Carl

Paver

Walkinman:  Ok, I looked at the other threads and they do not describe the main reason why this Template Error shows up with the new theme.php addbutton() system.  I'll try to write up something documentation-like to explain this.  The sys_menu and the sub_menu in the theme.php are not clearly organized into blocks you can copy & modify willy-nilly since other sections expect certain blocks to exist and unless you copy those blocks too and modify them, your theme breaks.  This correlation between separate sections makes it difficult to easily remove or modify something.  It will be clear once I organize my thoughts.

For now, try this.  In your theme.php file, look for this line:
addbutton($sub_menu_buttons,'{FAV_LNK}','{My Lightbox}','{FAV_TGT}','My Lightbox',$template_sub_menu_spacer);
and change the 5th parameter from 'My Lightbox' to 'favpics' as shown:
addbutton($sub_menu_buttons,'{FAV_LNK}','{My Lightbox}','{FAV_TGT}','favpics',$template_sub_menu_spacer);

That parameter is the name used in the BEGIN & END tags.  The assemble_template_buttons() function creates the BEGIN & END tags you cannot find.  In the "old" days, you would type in those tags manually as HTML.  (You can do that with the current system as well, which is why I'm sure gseb mentioned that.  The functions addbutton() and assemble_template_buttons() create the HTML blocks automatically for you.)  You have to use 'favpics' as your BEGIN & END label since you reference that later. 

Another solution is to keep the code I mentioned above as is and replace this line:
template_extract_block($template_sub_menu, 'favpics');
with this line:
template_extract_block($template_sub_menu, 'My Lightbox');
for the same reason.

It's recommended to do the first solution I give because Coppermine might assume you have a 'favpics' block and use that somewhere in the core code.  Right now it doesn't, but there are other buttons that are used in the core code and you cannot merely rename or remove the labels.  If you want to remove a button, for example the 'My Profile' button in the sys_menu, you have to use this line:
addbutton($sys_menu_buttons,'','','','my_profile','');
for the same reason others have said to keep the BEGIN & END tags and remove the stuff in between.  With this new addbutton() system, you have to keep the tag 'my_profile' and remove the stuff in between which is the three parameters in front of that tag in the addbutton() function.  Does that make sense?

So get into a good habit and don't touch that 5th parameter in the addbutton() function.  Leave that label alone since it's merely used as a comment label (for BEGIN & END tags); it won't show up in the web page except as a comment.  Remove the stuff before it if you don't want that button, and add a new button as desired.  Or modify the button, but keep that label as is so Coppermine knows where to find it, if it needs it.

That summarizes most of what needs to be said about using addbutton() successfully in theme.php.  I'll see if I can contribute a coherent doc section / post describing the overall picture and a few more details.

Paver

Oh, if you actually modified themes.inc.php as gseb suggested, you should take a "do over".  Don't modify themes.inc.php.  Instead copy the section from the sample/theme.php to your theme.php.  All theme customizations should go in your custom theme.  Don't touch the core script.  What did it ever do to you?  A lot of good, I say.  So leave the poor script alone.  Don't hack the core.  Are you Neo?  No, you are not.  Be a user, not a core-abuser.