Integrating Advanced Guestbook into CPG Integrating Advanced Guestbook into CPG
 

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

Integrating Advanced Guestbook into CPG

Started by calvinite, October 17, 2008, 09:22:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

calvinite

In keeping with GauGau's FAQ on contributing to this forum if it helps you, I offer the following mod/hack/integration because the forum has educated me in the ways of CPG and php of which I know just enough to make me crazy, being that I am about four months new to both; so I can't guarantee that this will work for everyone, nor do I know if I can be of help if you get stuck, but I'm willing to try.

Mostly, I'm truly amazed, and very happy, that I figured it out on my own after spending some time in this forum to get an idea of what direction I needed to go. I couldn't find exactly what I was wanting to do, though I could have overlooked it; but there was enough information in the forum to figure out how to do it. My sincere thanks to the dev team, moderators, and forum users for providing a wealth of information to use.

I am using CPG 1.4.19, which I integrated into my custom site and customized the theme. I wanted to integrate a guestbook for registered users, and not have its link visible unless the user was logged in. I've read the pros and cons here, of having it that way but it was decided it would be this way for now as it involves 30-60 year old private family photos that I was enlisted to digitize.

I looked at several different guestbooks and settled on Advanced Guestbook, which can be found at: http://www.proxy2.de/scripts.php It has some good features and there are also several other useful and well written scripts there too.

I installed the guestbook per the instructions in the readme file, and then modified it, through its styles menu under the admin login to fit my theme colors, though I had to make one mod by editing the body.php template file to change the font color of the navigation page number and total page indicators; and also added custom header graphics that match my site, and a link that would take users back to CPG after signing the book.

I didn't want to password the guestbook since users were already using a password to login. I figured out that I could use the custom link feature, but it would be visible to un-registered users on the login page and I couldn't figure out how to move it to the sys_menu and have it only appear when logged in.

I knew the My Profile link was only visible after login so studied CPG's theme.php and english.php files and followed my_profile and its variations till I though I understood. I used Notepad++ because it helps me understand the code better than notepad because of the color coding for comments, functions and etc. The structure of php is very similar to the basic programming language from the old days of DOS, at least to me. There I go telling my age.

NOTE: A very good practice when adding or removing code is to comment any code you add, and comment out any that you don't want to use. I use my nickname and current date. That way, if you get stuck you can easily find the lines and un-comment code you need back or comment out code giving trouble till you can figure it out or get help.

In theme.php under the heading, //HTML template for template sys_menu buttons, I copied the following line: addbutton($sys_menu_buttons,'{FAQ_LNK}','{FAQ_TITLE}','{FAQ_TGT}','faq',$template_sys_menu_spacer);

pasted it below the line copied and changed it to addbutton($sys_menu_buttons,'{GUESTBOOK_LNK}','{GUESTBOOK_TITLE}','{GUESTBOOK_TGT}','guestbook',$template_sys_menu_spacer); //Calvinite code 10-17-08

Under the heading, //Function for creating a main menu (SYS_MENU or SUB_MENU), I copied the line:
template_extract_block($template_sys_menu, 'my_profile');

and pasted it below the line copied and changed it to:
template_extract_block($template_sys_menu, 'guestbook'); //Calvinite code 10-17-08

Under the same heading, in the, $param = array(, section I copied the following code:
'{FAQ_TGT}' => "faq.php",
'{FAQ_TITLE}' => $lang_main_menu['faq_title'],
'{FAQ_LNK}' => $lang_main_menu['faq_lnk'],


and pasted it below the lines copied and changed it to:
'{GUESTBOOK_TGT}' => "http://www.MYURL.com/guestbook/index.php", //Calvinite code 10-17-08
'{GUESTBOOK_TITLE}' => $lang_main_menu['guestbook_title'], //Calvinite code 10-17-08
'{GUESTBOOK_LNK}' => $lang_main_menu['guestbook_lnk'], //Calvinite code 10-17-08


I uploaded this and of course it generated errors. It couldn't find the <-- BEGIN code block because I hadn't added anything to the $lang_main_menu array in the language file. So in english.php under the heading, //File theme.php, I copied the following code:
'faq_title' => 'Frequently Asked Questions on the picture gallery &quot;Coppermine&quot;',
'faq_lnk' => 'FAQ',


and pasted it below the lines copied, because that's where I wanted the new Guestbook link to appear, and changed it to:
'guestbook_title' => 'Guestbook for Registered members to leave comments.', // Calvinite code 10-07-08
'guestbook_lnk' => 'Guestbook', //Calvinite code 10-07-08


You can probably move the code up in the line to make it appear in a different palce in the sys_menu, though I didn't try it. I uploaded the file to my site and it works, with no bugs that I could find.

I hope this will be useful to someone, and to let the newer members know to stick with it. When I first started working with CPG and php I didn't think I'd ever be able to understand it. Yes, I have a long way to go to be as good as GauGau, Nibbler, Stramm, Tranz N Danz and others, but with time, who knows.

Again, thanks for your help, even though you might not know you did.

Calvinite
I started with nothing, and have most of it left.

Joachim Müller

Thanks for your contribution. I have added the zip archive of the guestbook script you mentioned to my posting in case the link should go down one day. Everybody should us the link above first and only if that fails should use the archive I have attached.
To add to the instructions above let me clarify: If one of the above mentioned sections that you need to modify don't exist in your custome theme (themes/your _theme/theme.php), then copy the corresponding section from the sample theme (themes/sample/theme.php) first.

Joachim Müller

Split reply by Ludo into a thread of it's own, as it is a full mod of it's own: Advanced Guestbook with coppermine theme

hlabout

Hi Calvinite,

Great explanation to add a extra Guestbook link>
I added the guestbook to my site and also added a guestbook link to my main menu.
All went well and the guestbook is working fine until i logg in as an administrator.
As soon as I login i get the following error message:

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

            <!-- BEGIN home -->
        <a href="{HOME_TGT}" title="{HOME_TITLE}">{HOME_LNK}</a> ::
  <!-- END home -->
<!-- BEGIN Contact -->
        <a href="index.php?file=contact/contact" title="Contact">Contact</a> ::
  <!-- END Contact -->
  <!-- BEGIN Guestbook -->
        <a href="{GUESTBOOK_TGT}" title="{GUESTBOOK_TITLE}">{GUESTBOOK_LNK}</a> ::
  <!-- END Guestbook -->  <!-- BEGIN my_gallery -->
        <a href="{MY_GAL_TGT}" title="{MY_GAL_TITLE}">{MY_GAL_LNK}</a> ::
  <!-- END my_gallery -->  <!-- BEGIN allow_memberlist -->
        <a href="{MEMBERLIST_TGT}" title="{MEMBERLIST_TITLE}">{MEMBERLIST_LNK}</a> ::
  <!-- END allow_memberlist -->      <!-- BEGIN leave_admin_mode -->
        <a href="{USR_MODE_TGT}" title="{USR_MODE_TITLE}">{USR_MODE_LNK}</a> ::
  <!-- END leave_admin_mode -->  <!-- BEGIN upload_pic -->
        <a href="{UPL_PIC_TGT}" title="{UPL_PIC_TITLE}">{UPL_PIC_LNK}</a> ::
  <!-- END upload_pic -->  <!-- BEGIN register -->
        <a href="{REGISTER_TGT}" title="{REGISTER_TITLE}">{REGISTER_LNK}</a> ::
  <!-- END register -->  <!-- BEGIN faq -->
        <a href="{FAQ_TGT}" title="{FAQ_TITLE}">{FAQ_LNK}</a> ::
  <!-- END faq -->
<!-- BEGIN Foto index -->
        <a href="index.php?file=photo_summary/summary" title="Foto index">Foto index</a> ::
  <!-- END Foto index -->
    <!-- BEGIN logout -->
        <a href="{LOGOUT_TGT}" title="{LOGOUT_TITLE}">{LOGOUT_LNK}</a>
  <!-- END logout ---

________________________________________________________________________________________________________________________________

But this is only happening when i log in, otherwise it is working fine.
So I suspect i need to add some more lines to my themes.inc.php but i don't know where.

I hope you can give me some advice on this issue.

Regards,

Harald

www.haraldlabout.nl/fotografie

Nibbler

The error message tells you what's wrong. You have written 'Guestbook' somewhere instead of 'guestbook'.

hlabout

Nibbler,

You are completely right, what a simple fix.
I have been occupied for a long time to find the problem.
Unfortunately it worked fine in the normal user mode and not in the admin mode.
Could not figure it out where the problem was.

So thanks for the GREAT advice, working fine now.

Harald

hlabout

All fine with the guestbook integration,no more error messages.
Only one question left.
At this moment to extra "guestbook" button/link only shows up in the normal user mode, thanks to Calvinites great mod.
Wat modification do i need to make to let the "guestbook" button/link shows up in the "admin mode

Harald

www.haraldlabout.nl

Joachim Müller

Hm, without actually trying this mod and just glimpsing at the suggested code changes I think that mod should work exactly as advertized and should add the link to the menu no matter if you're in admin mode or user mode. Maybe you have a different idea of what the user mode / admin mode toggle is. Anyway, this is beyond the scope of support on this announcement thread, so you should start a thread of your own, doing as suggested per board rules and post your issues with your custom menu item (because that's what it actually is) on your separate support thread. Zipping your custom theme folder and attaching that zip to your posting might be a good diea as well.

hlabout

Joachim,

Will start a own thread.

About your other comment on a post of mine: (cloud not reply o that post)

### Re: Suggestions to reduce DB queries? (not repeated)
« Reply #12 on: Yesterday at 07:14:15 »
   
You already asked the same question in another thread and got the answer
Quote from: Ludo on 17 August 2009, 08:45:20
You're off topic here: open your own thread with your request.

Nobody said that you should try to hijack another, unrelated thread. Instead, you have been told to start a thread of your own. Locking. Trying to talk to Leny using this thread is silly: he hasn't been active for more than a year, so he won't notice your reply.###

There is no need to be so rude in your answer.
I did not Hijack the other tread, as you can see that the second question of mine in that particular post was posted before Ludo told me to start another own tread.
I am not that familiar in the forum and was just looking for some answers to some questions of mine.
Perhaps I did not follow the exact "board rules" because I am not that familiar with them due to the fact I am quit new here on the forum.
I will have a better look in to the board rules but I certainly did not Hijack  >:( another thread as you suggested.

Harald





Joachim Müller

Now you clutter this thread with a quote from another thread? You're not listening apparently. Banning you for a week from posting. Review your attitude or you'll get banned permanently.

calvinite

For anyone that upgraded their Coppermine installation to 1.5.12 and had Advanced Guestbook integrated into their installation, and had used my instructions to add a link to the Coppermine menu, (As in this post: http://forum.coppermine-gallery.net/index.php/topic,55796.0.html); you may find that the guestbook no longer works.

The following instructions are an update to get it to work with Coppermine 1.5.12. My apologies for taking so long to get around to doing this, but I've been very busy working on an Associates degree in Visual Communications and my free time has been scarce. Thank goodness I'm half way there now.

In the theme.php file, of the theme you are using, (Mine is a custom theme based on the Curve theme.)

Find:

    addbutton($sub_menu_buttons,'{CUSTOM_LNK_LNK}','{CUSTOM_LNK_TITLE}','{CUSTOM_LNK_TGT}','custom_link',$template_sub_menu_spacer);


Add the following code after it:

    addbutton($sub_menu_buttons,'{GUESTBOOK_LNK}','{GUESTBOOK_TITLE}','{GUESTBOOK_TGT}','guestbook_link',$template_sub_menu_spacer, 'rel="nofollow"');


Find the following section:

    '{BROWSEBYDATE_TGT}' => 'calendar.php',
    '{BROWSEBYDATE_LNK}' => $lang_main_menu['browse_by_date_lnk'],
    '{BROWSEBYDATE_TITLE}' => $lang_main_menu['browse_by_date_title'],
    '{BROWSEBYDATE_ICO}' => cpg_fetch_icon('calendar', 1),


Add the following code after it:

    '{GUESTBOOK_TGT}' => "guestbook.php",
    '{GUESTBOOK_TITLE}' => $lang_main_menu['guestbook_title'],
    '{GUESTBOOK_LNK}' => $lang_main_menu['guestbook_lnk'],


In your language file, mine is english.php,

Find:

    $lang_main_menu['fav_title'] = 'Go to my favorites';
    $lang_main_menu['fav_lnk'] = 'My Favorites';


Add the following code after it:

    $lang_main_menu['guestbook_title'] = 'Sign our guestbook';
    $lang_main_menu['guestbook_lnk'] = 'Guestbook';


This example should place the Guestbook link between the Favorites and Search links on the menu. If you want to move the link to another location, you should be able to move the code location in the array section.

I also suggest you add a comment line, similar to the following,

// added by calvinite 05-31-2011

to each line or section of code you add to your files, so you can use the search function in your favorite code editor, to make it easier to locate in the event you have any bugs.


Joachim, I'd appreciate your evaluation of the code to ensure I didn't introduce any unnecessary code or errors.

Thanks,

calvinite
I started with nothing, and have most of it left.