If you are not registered or logged in, you may still use these forums but with limited features. Show recent topics
  [Search] Search   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [FAQ]  FAQ 
[Register] Register / 
[Login] Login 
How To Change The Drop Down Menu In Advanced Guestbook  XML
Forum Index » Support Forum
Author Message
Trevor
Student
[Avatar]

Joined: 17/06/2004 02:53:11
Messages: 67
Location: UK
Offline

This subject seems to come up quite a bit and has caused a few problems of late. So... instructions to add links to the drop down menu, it works in versions 2.2 and 2.3 - don't know about other versions.

Quick Instructions - if you're familiar with this sort of stuff, Step By Step Instructions (further down) if you're not.

QUICK INSTRUCTIONS

1: Insert the following right at the begining of the header.php file...

<script language="Javascript">
<!--
function urlJump(target,selObj) {
var optionValue = selObj.options[selObj.selectedIndex].value;
var isURL = /http:/;
var regMatch = isURL.test(optionValue);
if(regMatch == true) {
eval(target+".location='"+selObj.options[selObj.selectedIndex].value+"'");
}
}
// -->
</script>


2: Go to where the jump menu is generated in the gb.class.php file (about line 60) and make the changes so it reads as below. The blue bit is the code that was already there, the red bit is what you've just added...

function generate_JumpMenu() {
$menu_array[] = "<select name=\"entry\" onChange=\"urlJump('self',this)\" class=\"select\">";
$menu_array[] = "<option value=\"http://www.yahoo.com\" class=\"select\">Yahoo</option>";
$menu_array[] = "<option value=\"http://www.google.com\" class=\"select\">Google</option>";

$menu_array[] = "<option value=\"0\" selected>".$this->db->LANG["FormSelect"]."</option>";

3: Edit the Yahoo and Google bits to whatever suits.

4: Any links you add at this stage don't require the 'go' button as they're jump links. But... as the number of entries in your guestbook grows more pages will be added with links automatically added to the menu.

If you want to make all menu entries into jump links you'll need to edit the script where menu items are added and change the onChange=\"urlJump part. You then don't need the 'go' button. Delete the following if you want to remove it...

$menu_array[] = "<input type=\"submit\" value=\"".$this->db->LANG["FormButton"]."\" class=\"input\">";



STEP BY STEP INSTRUCTIONS

1: You'll change the following files so good idea to make backups first: gb.class.php in the lib subdirectory and header.php in the templates subdirectory.

2: Open header.php. Copy and paste the following right at the begining (even before the metatags).

<script language="Javascript">
<!--
function urlJump(target,selObj) {
var optionValue = selObj.options[selObj.selectedIndex].value;
var isURL = /http:/;
var regMatch = isURL.test(optionValue);
if(regMatch == true) {
eval(target+".location='"+selObj.options[selObj.selectedIndex].value+"'");
}
}
// -->
</script>


3: Save the changes. Now open gb.class.php. These changes add two links, details later about how to add more or less.

4: Scroll down to the following line (with line numbering on it's somewhere around line 60)...

function generate_JumpMenu() {

5: Copy and paste the following so it starts on a new line after the script quoted above (don't worry about the Yahoo and Google bit for now)...

$menu_array[] = "<select name=\"entry\" onChange=\"urlJump('self',this)\" class=\"select\">";
$menu_array[] = "<option value=\"http://www.yahoo.com\" class=\"select\">Yahoo</option>";
$menu_array[] = "<option value=\"http://www.google.com\" class=\"select\">Google</option>";


6: OK, now you should have the following - the blue bit is the code that was already there, the red bit is what you've just added...

function generate_JumpMenu() {
$menu_array[] = "<select name=\"entry\" onChange=\"urlJump('self',this)\" class=\"select\">";
$menu_array[] = "<option value=\"http://www.yahoo.com\" class=\"select\">Yahoo</option>";
$menu_array[] = "<option value=\"http://www.google.com\" class=\"select\">Google</option>";


7: Now delete the 'old' part of the script. That's the bit that comes after what you've just copied and pasted and BEFORE the following...

$menu_array[] = "<option value=\"0\" selected>".$this->db->LANG["FormSelect"]."</option>";

8: All being well you've now got the following (blue was already there, red is what you've added)...

function generate_JumpMenu() {
$menu_array[] = "<select name=\"entry\" onChange=\"urlJump('self',this)\" class=\"select\">";
$menu_array[] = "<option value=\"http://www.yahoo.com\" class=\"select\">Yahoo</option>";
$menu_array[] = "<option value=\"http://www.google.com\" class=\"select\">Google</option>";

$menu_array[] = "<option value=\"0\" selected>".$this->db->LANG["FormSelect"]."</option>";

9: If you want to check it at this point then save the changes (don't close the file as there's more changes to make), view your guestbook page and check the Yahoo and Google links in the menu.

10: If you only want to add one link then delete the following...

$menu_array[] = "<option value=\"http://www.yahoo.com\" class=\"select\">Yahoo</option>";

11: If you want to add more than 2 links then copy and paste the following as many times as you want...

$menu_array[] = "<option value=\"http://www.yahoo.com\" class=\"select\">Yahoo</option>";

For example, the following allows you to add 5 links (blue is original text, orange is what you added earlier, red is what you need to add now)...

function generate_JumpMenu() {
$menu_array[] = "<select name=\"entry\" onChange=\"urlJump('self',this)\" class=\"select\">";
$menu_array[] = "<option value=\"http://www.yahoo.com\" class=\"select\">Yahoo</option>";
$menu_array[] = "<option value=\"http://www.google.com\" class=\"select\">Google</option>";

$menu_array[] = "<option value=\"http://www.yahoo.com\" class=\"select\">Yahoo</option>";
$menu_array[] = "<option value=\"http://www.yahoo.com\" class=\"select\">Yahoo</option>";
$menu_array[] = "<option value=\"http://www.yahoo.com\" class=\"select\">Yahoo</option>";

$menu_array[] = "<option value=\"0\" selected>".$this->db->LANG["FormSelect"]."</option>";

12: OK, you've now got as many new links on the menu as you want - just go through the script you've added and replace any instances of yahoo.com and google.com with the URL's you want to link to. Make sure there's a backslash at the end of the URL (e.g. http://www.yahoo.com\ is correct, http://www.yahoo.com isn't).

13: Go back through the script and replace instances of Yahoo and Google with appropriate descriptions for the links.

14: An example of an edited line that links to my-web-site.com/home from a menu entry that says Home Page would look like...

$menu_array[] = "<option value=\"http://www.my-web-site.com/home\" class=\"select\">Home Page</option>"; .

15: What you've got now is a jump menu - when you click one of the entries you've just added you go straight to the page without needing to hit the go button. However, the guestbook will automatically add more links to the menu as your guestbook grows and entries are displayed on more than one page. To link to these pages you'll need to hit the 'go' button.

16: That's it. Save it and test it. If it all works then fine, if not then check it and if still no joy then reinstate the original versions which you backed up earlier, resign yourself to not having links in your menu, grab a cold beer and chill out by watching some really funny toons here <<<http://www.weebls-stuff.com/toons>>>

=======================================================================

Questions, problems, comments about the above? E-mail to guestbook at kahlil dot org, if I've got a bit of spare time I'll try and help.

Trevor
[Email] [WWW] [Yahoo!] aim icon [MSN] [ICQ]
amber222
Graduate

Joined: 07/05/2004 21:13:07
Messages: 586
Offline

Thanks. Very good instructions.
Anonymous



Thanks a bunch

Great instructions!

Jay
JTD
Graduate

Joined: 08/05/2004 21:52:50
Messages: 529
Location: Arkansas
Offline

*BUMP* To keep this at the top.

LINK-> Use Lazarus Guestbook
[WWW] [Yahoo!] aim icon [MSN]
Funky Monk
Beginner

Joined: 14/08/2003 13:10:14
Messages: 20
Location: Ballynahinch, Northern Ireland
Offline

Nice. Actually what I want to do is remove the drop-down menu. I don't need it and would rather leave it out. Which files do I have to edit and what do I have to do?
[WWW]
Trevor
Student
[Avatar]

Joined: 17/06/2004 02:53:11
Messages: 67
Location: UK
Offline

Do you really want to delete the menu?

When your guestbook has too many entries to display on one page (the number depends what you've set it to) then links are automatically added to the menu to the other pages. No menu = no links to the other pages.

If you're sure you want rid of it then open gb.class.php and comment out all the relevant lines (starting at about line 60) - see the colored bits in the post above for the actual script to comment out.

Trevor
[Email] [WWW] [Yahoo!] aim icon [MSN] [ICQ]
Funky Monk
Beginner

Joined: 14/08/2003 13:10:14
Messages: 20
Location: Ballynahinch, Northern Ireland
Offline

Er...no! Didn't realise that was what it was for.
[WWW]
Anonymous



Hi when i select any thing from the drop down menu EG: google or yahoo it jumps straight to that page like it should do..but if i select a guestbook page EG:20-40 or 40-60 it doesnot auto jump and requires a click on the go button (which i had to put back for this purpose)
Trevor
Student
[Avatar]

Joined: 17/06/2004 02:53:11
Messages: 67
Location: UK
Offline

Thanks TanagerDave - I forgot to mention about having to edit other parts of the script to make the automatic entries into jump links as well. I did it once but can't remember off the top of my head what the changes were otherwise I'd mention them here.

I've also edited the original post to take account of what you've said.

Hope everything else is OK with your guestbook.

Trevor
[Email] [WWW] [Yahoo!] aim icon [MSN] [ICQ]
Anonymous



yes everything is perfect thanks,,just had to leave the go button there for now but thats not really a problem
The Old Man
Beginner

Joined: 10/09/2004 12:52:00
Messages: 7
Location: UK
Offline

Hi,
Thank you for the excellent mod. Works great!
Regards,
Graham.
darrenabela
Beginner

Joined: 22/01/2004 15:59:54
Messages: 7
Location: London
Offline

hi there,

I just moved my website to a new server host, and had a nightmare in setting up GB again.. Finally its done however I copied the gb.class.php file across to keep the Back to Menu selction, however when ever you use it I get the error below:

Query Error
--------------------------------------------------------------------------------

MySQL Error : Query Error
Error Number: 1064 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'http://www.jesmonddenehotel.com/, 10' at line 1
Date : Wed, October 13, 2004 15:26:50
IP : 205.228.81.22
Browser : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; msie6xpv1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
Referer : http://www.jesmonddenehotel.co.uk/guestbook/index.php
PHP Version : 4.3.9
OS : Linux
Server : Apache/1.3.31 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.9 FrontPage/5.0.2.2634a mod_ssl/2.8.19 OpenSSL/0.9.7a
Server Name : www.jesmonddenehotel.co.uk



Any idea?
[Email] [WWW]
Carbonize
Master
[Avatar]

Joined: 12/06/2003 19:26:08
Messages: 4289
Location: Bristol, UK
Offline

You remember to put the javascript in the head section as mentioned in the very first post of this thread?

Carbonize
I am not the maker of the Advanced Guestbook

get Lazarus
[Email] [WWW] [Yahoo!] aim icon [MSN] [ICQ]
Anonymous



thanks mate that worked, although the go button doesnt have to be pressed, it just goes back to homepage....is there any more code im missing?
Trevor
Student
[Avatar]

Joined: 17/06/2004 02:53:11
Messages: 67
Location: UK
Offline

If you've made the changes in the instructions above then there's nothing more to do.


About the go button...

4: Any links you add at this stage don't require the 'go' button as they're jump links. But... as the number of entries in your guestbook grows more pages will be added with links automatically added to the menu.

If you want to make all menu entries into jump links you'll need to edit the script where menu items are added and change the onChange=\"urlJump part. You then don't need the 'go' button. Delete the following if you want to remove it...

$menu_array[] = "<input type=\"submit\" value=\"".$this->db->LANG["FormButton"]."\" class=\"input\">";


Trevor
[Email] [WWW] [Yahoo!] aim icon [MSN] [ICQ]
 
Forum Index » Support Forum
Go to:   
Based on the open source JForum