View Full Version : AnyLink Drop Down Menu: Dynamic Links?

Monaco Franze
04-06-2006, 12:53 PM
Hi !!

I've downlaoded the AnyLink Drop Down Menu (http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm ) and implemented it half-sucessfull in my website (a phpBB2 board).

Okay, everything would work great, but there is a problem with the links within the menu.

I would like to use this menu in the thread-view of my forum, when you click on a poster's name, see here:

[Menu closed]

[Menu opened]

In the Menu there are the typical Links known from board systems:
- Go to users profile
- Send him / her a private Message
- Send him / her a Email
- Search for his / her posts
and so on.

Okay, the links are generated in the .php file, so in the .html file, that belongs to the .php file, you just have a variable to place.

For example for the Email function:
This code is in the .php file

$email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
that generates this variable

for the html file

and thats the problem:
This variable would work good when you put in the usual way somewhere in the .html file, but the in the code of the javascript (where you have to add your links), it doesen't work.

cause when you use the variable, you can, no, you MUST use it as it is ({postrow.EMAIL}), and not in this way: <a href="{postrow.EMAIL}">Send Email</a>

My question is: can anyone patch this javascript for me, that it is possible to add this variables?
Like if you would say to the javascript "He guy, look here: No need for the <a tag>, it's already generated in the .php file!"

would be great!
thanks in advance guys! ;)

edit: this is how it sould be.. but like above said, doesn't work.
(if you use this code, only the first column called "Optionen" is showed)

//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="javascript:void(0)">Optionen</a>'
var menuwidth='180px' //default menu width
var menubgcolor='f9f9f9' //menu bgcolor
var disappeardelay=999999999999999999 //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

04-06-2006, 05:26 PM
In javascript, the {} characters contain something that is separate from everything else, that must be considered by itself before being evaluated by the code around it. If you want the script to treat them as normal characters you can try escaping them:


Or try something like so (using the raw code and escaping it for javascript):

menu2[1]="'<a href=\"' . $email_uri . '\">' . $lang['Send_email'] . '</a>'"

Monaco Franze
04-10-2006, 02:41 PM
Ok, I solved several problems on my own.
The menu works now (almost) fine, there's only one more problem that has to be solved.

ok, as I already explained in the first post, i use it on a forum in the "thread-view"-site!

If a thread for example has 6 posts in it and I click on the username of this user, who has made the last post on that page of the thread, everything is fine, the links of the menu link all to the user individual links (his profile, his posts, his website, his gallery, etc.).
BUT: If I click on any other posters name (e.g. the first poster or the 4th of this page of the thread), all the links are wrong, they all lead to the personal data of the last poster on this page of the thread, and not of the user, whose name I actually clicked!!!!

i hope you understand what I mean..

Here is the relevant file (as .txt).. - Click here - (http://people.freenet.de/zettlzone/viewtopic_body.txt)

It would be greater than great if someone can solve this problem!!

04-10-2006, 07:15 PM
The problem most likely is that this:

menu2[0]='<a href="javascript:void(0)">&raquo; Optionen</a>'

is written out and parsed by the browser at the time the page is first loaded. These values will not change unless you write some code to reinitialize them. Like if each time a different post in the thread receives focus or however that is done, if that changes the values represented by those tokens have it also run a function like:

function updateTokens(){
menu2[0]='<a href="javascript:void(0)">&raquo; Optionen</a>'

So let's say a given post in a thread is focused on by clicking a link like this or something:

<a href="whatever.php?postcount++">Next</a>

It could be changed to:

<a href="whatever.php?postcount++" onclick="updateTokens();return true;">Next</a>

or perhaps:

<a href="whatever.php?postcount++" onclick="setTimeout('updateTokens()', 2000);return true;">Next</a>

If the token's values don't change right away.

Monaco Franze
04-11-2006, 11:36 AM
That would be possible, improves however the situation not real, since further the complete Script for each post on the page is loaded with...

Any ideas how to make it possible that the script only has to be loaded once and not with single every post made on the thread-view page..?

Monaco Franze
04-11-2006, 02:33 PM
Ok i tried it now another way, so that the javascript only has to be loaded once..

but it doesen't work..

perhaps someone can tell me whats wrong?
cause it should work this way.. but doesen't. :-(

(search in both files for "menu" then you will quick fast my changes!)

please guys .. help me.. i think it's already done.. only a little mistake is there.. but what??!?