Results 1 to 6 of 6

Thread: AnyLink Drop Down Menu: Dynamic Links?

  1. #1
    Join Date
    Apr 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default AnyLink Drop Down Menu: Dynamic Links?

    Hi !!

    I've downlaoded the AnyLink Drop Down Menu (http://www.dynamicdrive.com/dynamici...pmenuindex.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
    Code:
    $email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
    that generates this variable
    Code:
    {postrow.EMAIL}
    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)
    Code:
    //Contents for menu 2, and so on
    var menu2=new Array()
    menu2[0]='<a href="javascript:void(0)">Optionen</a>'
    menu2[1]='{postrow.PROFILE}'
    menu2[2]='{postrow.PM}'
    menu2[3]='{postrow.SEARCH}'
    menu2[4]='{postrow.EMAIL}'
    menu2[5]='{postrow.WWW}'
    menu2[6]='{postrow.ALBUM}'
    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
    Last edited by Monaco Franze; 04-06-2006 at 01:23 PM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    menu2[1]='\{postrow.PROFILE\}'
    Or try something like so (using the raw code and escaping it for javascript):

    Code:
    menu2[1]="'<a href=\"' . $email_uri . '\">' . $lang['Send_email'] . '</a>'"
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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 -


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

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The problem most likely is that this:

    Code:
    menu2[0]='<a href="javascript:void(0)">&raquo; Optionen</a>'
    menu2[1]='{postrow.PROFILE}'
    menu2[2]='{postrow.PM}'
    menu2[3]='{postrow.SEARCH}'
    menu2[4]='{postrow.EMAIL}'
    menu2[5]='{postrow.WWW}'
    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:

    Code:
    function updateTokens(){
    menu2[0]='<a href="javascript:void(0)">&raquo; Optionen</a>'
    menu2[1]='{postrow.PROFILE}'
    menu2[2]='{postrow.PM}'
    menu2[3]='{postrow.SEARCH}'
    menu2[4]='{postrow.EMAIL}'
    menu2[5]='{postrow.WWW}'
    }
    So let's say a given post in a thread is focused on by clicking a link like this or something:

    HTML Code:
    <a href="whatever.php?postcount++">Next</a>
    It could be changed to:

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

    HTML Code:
    <a href="whatever.php?postcount++" onclick="setTimeout('updateTokens()', 2000);return true;">Next</a>
    If the token's values don't change right away.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Apr 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

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

  6. #6
    Join Date
    Apr 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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??!?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •