forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: Walkinman on January 11, 2006, 09:37:12 am

Title: Add to Favorites as Text and button
Post by: Walkinman 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
Title: Re: Add to Favorites as Text and button
Post by: Walkinman 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
Title: Re: Add to Favorites as Text and button
Post by: Walkinman 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
Title: Re: Add to Favorites as Text and button
Post by: Tranz 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).
Title: Re: Add to Favorites as Text and button
Post by: Walkinman 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
Title: Re: Add to Favorites as Text and button
Post by: Walkinman 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
Title: Re: Add to Favorites as Text and button
Post by: Joachim Müller 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.
Title: Re: Add to Favorites as Text and button
Post by: Walkinman 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
Title: Re: Add to Favorites as Text and button
Post by: Joachim Müller on January 12, 2006, 08:28:21 am
you're using cpg1.4.2 - upgrade to cpg1.4.3
Title: Re: Add to Favorites as Text and button
Post by: Walkinman 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
Title: Re: Add to Favorites as Text and button
Post by: Walkinman 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
Title: Re: Add to Favorites as Text and button
Post by: Walkinman 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
Title: Re: Add to Favorites as Text and button
Post by: qseb 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,
Title: Re: Add to Favorites as Text and button
Post by: Walkinman 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
Title: Re: Add to Favorites as Text and button
Post by: qseb 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  ???
Title: Re: Add to Favorites as Text and button
Post by: Walkinman 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
Title: Re: Add to Favorites as Text and button
Post by: Paver 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.
Title: Re: Add to Favorites as Text and button
Post by: Walkinman 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
Title: Re: Add to Favorites as Text and button
Post by: Paver 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.
Title: Re: Add to Favorites as Text and button
Post by: Paver 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.
Title: Re: Add to Favorites as Text and button
Post by: Walkinman on January 20, 2006, 08:58:00 pm
Hey Paver,

Sorry it took me a while to get back with you, I've been out. I really appreciate the help. Your comments made sense to me, and helped a lot, thanks. When you say "themes.inc.php", you mean the sample theme, correct? I can't even find a themes.inc.php file. I haven't modified the sample theme at all, sorry if what I said implied that. I've copied it into the mytheme.php file and saved that one. And no, I'm certainly not a Neo.  ;)

As for the modification, it kinda half worked. It still show the button "Add to My Lightbox", and allows that to be clicked, yielding the "Remove from Lightbox" button. But it simply removed the "My Lightbox" text link from the Sub-menu, correct? What I'd really like is to have the actual "Add to My Lightbox" button simply not appear unless a User is logged in. Is that possible? Just as the Ecard button doesn't show unless a User is Logged in. I could still leave the "My Lightbox" text link in the Submenu, but just not have the option to add to a lightbox unless a User is logged in.

Thanks again for your help, it's invaluable.

Cheers

Carl

Title: Re: Add to Favorites as Text and button
Post by: Paver on January 20, 2006, 09:44:06 pm
"A while" would be a week; overnight is a pretty quick response. 

All the .inc.php files are in the include folder.  The themes.inc.php file is in there and has all the default functions & variables that are used if you don't override them in your theme. 

My answer was about fixing your error; the error message referred to the sys_menu button that you renamed to 'My Lightbox'.  My last post deals with the sys_menu only.

gseb suggested the solution to your "Add to Lightbox" question.  I'll give mine.  Go to your theme.php file and look for these lines:
Code: [Select]
if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
        $favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . ' ><img src="images/addlight.jpg" align="middle" border="0" alt="" title="'. $lang_picinfo['addFav'] . '" /></a>';
    } else {
        $favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . ' ><img src="images/remlight.jpg" align="middle" border="0" alt="" title="'. $lang_picinfo['remFav'] . '" /></a>';
    }
Add before it one line and after it three lines as shown:
Code: [Select]
if (USER_ID) {
if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
             $favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . ' ><img src="images/addlight.jpg" align="middle" border="0" alt="" title="'. $lang_picinfo['addFav'] . '" /></a>';
       } else {
             $favorite = '<a href=addfav.php?pid=' . $CURRENT_PIC_DATA['pid'] . ' ><img src="images/remlight.jpg" align="middle" border="0" alt="" title="'. $lang_picinfo['remFav'] . '" /></a>';
       }
} else {
       $favorite = '';
}

Also, this is not an error but a redundancy that is errrr... redundant.  You have two of the following lines in the same $params definition.  Look for this and remove one of them:
Code: [Select]
        '{FAVORITE}' => $favorite,
I didn't try out your theme file, but this should cover your question I think.
Title: Re: Add to Favorites as Text and button
Post by: Walkinman on January 21, 2006, 01:53:02 am
hey Paver,

Thank you so much. That works perfectly.

I really appreciate your help.

Cheers

Carl

Title: Re: Add to Favorites as Text and button
Post by: Paver on January 21, 2006, 02:00:52 am
You're welcome.  I'm glad you're up & running.  Please modify the first post of this thread to have an icon of "Solved".
Title: Re: Add to Favorites as Text and button
Post by: Walkinman on January 21, 2006, 05:45:22 am
Hey paver,

I don't think I can mark it 'solved', can I? According to this:

http://forum.coppermine-gallery.net/index.php?topic=18644.msg86001#msg86001

and this:

http://forum.coppermine-gallery.net/index.php?topic=19474.msg89634#msg89634

I can't do it. Or has something changed?

Cheers

Carl
Title: Re: Add to Favorites as Text and button
Post by: Joachim Müller on January 21, 2006, 05:58:47 am
@Paver: Walkinman is right, regular users can't do that, only members of special groups (moderators, supporters, dev team members) can.
Title: Re: Add to Favorites as Text and button
Post by: Paver on January 21, 2006, 06:29:51 am
GauGau: Ok, good to know.  Walkinman is to be commended for the relevant searching.  I asked on the dev board about this since I thought it was an "inside" question.  But since you brought up "Supporter" here and I have been designated as one, do I just change any of my posts in the thread as "Solved" and that marks the whole thread?  I assumed I had to have access to the first thread to do so.  I read the initial docs on the SMF site but didn't see such an answer and planned to download & read the manual but haven't yet.
Title: Re: Add to Favorites as Text and button
Post by: Joachim Müller on January 21, 2006, 06:44:34 am
It doesn't come with SMF, it's a custom hack I applied. You have to edit the first posting in a thread to mark the whole thread.
Title: Re: Add to Favorites as Text and button
Post by: modiba on April 05, 2006, 04:15:23 am
Hello,

I am trying to add a GIF button next to the E-Card button will add the image to the user's favorites.

I have read through this post over and over again but can't get it to work...

Is it possible to just possible to insert the image in HTML and hardcode a link which will add a photo to the favorites?
If so, what would the code be?

Thank you,
Greg
Title: Re: Add to Favorites as Text and button
Post by: zac on May 05, 2007, 02:10:15 am
hello all.. sorry to bump such an old post but my problem is really specific to this mod.. I followed all the instructions and the button does work in adding the image to the favorites.. however after clicking the button and the gallery does the reload it returns with the selected album/files does not exist error.  The add to favorties link in the info panel works fine and does not have this error.  I am also running the add to lightbox plugin.. could this be screwing it up.  Thanks in advance for pointing me in the direction where I can solve this problem.


p.s.  LOL Paver

Quote
Are you Neo?  No, you are not.  Be a user, not a core-abuser.
Title: Re: Add to Favorites as Text and button
Post by: Nibbler on May 05, 2007, 02:42:35 am
You need to add a redirect parameter to the link, look at the built-in link to see how this works. It was added as a bugfix since this mod was posted.
Title: Re: Add to Favorites as Text and button
Post by: zac on May 05, 2007, 03:01:49 am
thanks nibbler but  ??? ???  sorry i  am not sure what you mean..  built-in link?