drop down menu that opens link currentpage + ?php=

Discussion in 'Programming' started by saturn100, Jun 23, 2011.

  1. #1
    OK I will try and explain myself first off I am designing a site in oscommerce
    The site is mulit lingual and has 4 flags in a row representing different langauges
    All that works fine buy I would like to create my own drop down list for the menu and when you click on the link it translates the page
    It does this already but the code is quite complicated to edit and I cant figgure it out

    Currently when you click on the flag to translate the page it opens a new page lile this
    mydomain.com/contactus.php?language=en

    What I would like or need is code that will repon what ever the current page and add in that extra line of code
    so it will open "currentpage?language=en

    Is this posible with code PHP or javascript or anything else
    Also I would need to add in an IF or ELSE statement

    saying something like

    If page url="mydomain.com" open mydomain.com/index.php?language=en

    else open
    currenturl +?language=en

    Thanks to anyone who can help
     
    saturn100, Jun 23, 2011 IP
  2. ntomsheck

    ntomsheck Peon

    Messages:
    87
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    echo $_SERVER['PHP_SELF'] . "?language=" . $selectedlanguage;

    That'll be 5 dollars.
    Haha kidding. Honestly, I'm not sure if that's what you were looking for, but it's what I gathered from your post. $_SERVER['PHP_SELF'] will always output /currentpage.php
     
    ntomsheck, Jun 23, 2011 IP
  3. saturn100

    saturn100 Well-Known Member

    Messages:
    465
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #3
    thanks
    where do i place that is a <a> tag
     
    saturn100, Jun 24, 2011 IP
  4. ntomsheck

    ntomsheck Peon

    Messages:
    87
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If I understand your question correctly, you would do something like <a href="<?php echo $_SERVER['PHP_SELF'] . "?language=" . $selectedlanguage; ?>">Your link in english</a>
     
    ntomsheck, Jun 27, 2011 IP
  5. saturn100

    saturn100 Well-Known Member

    Messages:
    465
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #5
    Thanks that is great
    Is it possible to place the if statement in that as well

    I really need to learn to type ;)
     
    saturn100, Jun 27, 2011 IP
  6. ntomsheck

    ntomsheck Peon

    Messages:
    87
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Have you tried it yet? You shouldn't need an if statement. When you're on www.mydomain.com, PHP_SELF should point right to index.php (unless you changed configs to a different name of index).
     
    ntomsheck, Jun 27, 2011 IP