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] 2   Go Down

Author Topic: Add to Favorites as Text and button  (Read 21346 times)

0 Members and 1 Guest are viewing this topic.

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Add to Favorites as Text and button
« on: January 11, 2006, 09:37:12 am »

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
« Last Edit: January 21, 2006, 05:59:44 am by TranzNDance »
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Add to Favorites as Text and button
« Reply #1 on: January 11, 2006, 08:49:27 pm »

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
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Add to Favorites as Text and button
« Reply #2 on: January 12, 2006, 07:12:53 am »

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
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Add to Favorites as Text and button
« Reply #3 on: January 12, 2006, 07:16:49 am »

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

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Add to Favorites as Text and button
« Reply #4 on: January 12, 2006, 07:44:54 am »

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
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Add to Favorites as Text and button
« Reply #5 on: January 12, 2006, 07:56:22 am »

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
« Last Edit: January 12, 2006, 08:03:08 am by Walkinman »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Add to Favorites as Text and button
« Reply #6 on: January 12, 2006, 08:07:41 am »

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:
Code: [Select]
// 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.
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Add to Favorites as Text and button
« Reply #7 on: January 12, 2006, 08:17:15 am »

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
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Add to Favorites as Text and button
« Reply #8 on: January 12, 2006, 08:28:21 am »

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

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Add to Favorites as Text and button
« Reply #9 on: January 12, 2006, 08:34:50 am »

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
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Add to Favorites as Text and button
« Reply #10 on: January 12, 2006, 07:21:15 pm »

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
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Add to Favorites as Text and button
« Reply #11 on: January 17, 2006, 04:58:09 am »

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
Logged

qseb

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 8
Re: Add to Favorites as Text and button
« Reply #12 on: January 17, 2006, 09:39:11 pm »

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
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>
add
Code: [Select]
<td align="center" valign="middle" class="navmenu" width="48">
                        {FAVORITE}
                </td>

2/ replace
   
Code: [Select]
global $CONFIG, $CURRENT_PIC_DATA, $meta_nav, $THEME_DIR ; //$PHP_SELF,with
 
Code: [Select]
global $CONFIG, $CURRENT_PIC_DATA, $meta_nav, $THEME_DIR, $FAVPICS ; //$PHP_SELF,

3/ after
Code: [Select]
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
Code: [Select]
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
Code: [Select]
'{ECARD_TGT}' => $ecard_tgt,
'{ECARD_TITLE}' => $ecard_title,
add
Code: [Select]
'{FAVORITE}' => $favorite,
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Add to Favorites as Text and button
« Reply #13 on: January 18, 2006, 07:48:56 pm »

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
Logged

qseb

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 8
Re: Add to Favorites as Text and button
« Reply #14 on: January 18, 2006, 10:01:37 pm »

1* after
Code: [Select]
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
Code: [Select]
template_extract_block($template_sub_menu, 'favpics');
and check that your theme.php in template dir has <!-- BEGIN favpics --> and <!-- END favpics --> around
Code: [Select]
<a href="{FAV_TGT}" title="{FAV_LNK}">{FAV_LNK}</a>
2* htlm code:
Code: [Select]
<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  ???
« Last Edit: January 19, 2006, 12:01:47 am by qseb »
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Add to Favorites as Text and button
« Reply #15 on: January 19, 2006, 04:39:06 am »

Hey Gseb,

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

Code: [Select]
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:

Code: [Select]
<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
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Add to Favorites as Text and button
« Reply #16 on: January 19, 2006, 05:54:02 am »

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.
Logged

Walkinman

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 380
    • Skolai Images - Nature, Travel and Adventure stock photos
Re: Add to Favorites as Text and button
« Reply #17 on: January 19, 2006, 07:37:41 am »

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:

Code: [Select]
<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
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Add to Favorites as Text and button
« Reply #18 on: January 20, 2006, 03:33:24 am »

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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
template_extract_block($template_sub_menu, 'favpics');with this line:
Code: [Select]
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:
Code: [Select]
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.
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Add to Favorites as Text and button
« Reply #19 on: January 20, 2006, 03:53:07 am »

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.
Logged
Pages: [1] 2   Go Up
 

Page created in 0.057 seconds with 19 queries.