Skip to main content
Inspiring
September 18, 2006
Answered

include current page name in link address

  • September 18, 2006
  • 13 replies
  • 1383 views
is there a piece of code I can use to include the current page name in a link to another folde rwhich contains and mirror image of the site structure but in a different language?

something like this:

<a href="../english/current-page.php">

That way whenever someone clicks on the link they will go to the right (same-name) page in whichever language they want. If it's possible I can simply add this lineto the template that governs each language an dmy job is done. If it's not possible, I have a long slog ahead of me, typing in each one individually.


Can anyone help?

Cheers


Dave

This topic has been closed for replies.
Correct answer davecheet
I owe you an apolgy David,

I couldn't get to the bottom of what was going wrong, so I reconstructed the templates very carefully and included the echo basename($_SERVER['SCRIPT_NAME']) bit that you suggested. It works absolutely perfectly now.

Thanks very much for your help.


Dave

13 replies

September 18, 2006
I put a tutorial on my PHP site about how to do this:

http://www.php-newbie.com/index.php?option=com_content&task=view&id=17&Itemid=26
Inspiring
September 18, 2006
Murray *ACE* wrote:
> If you are using PHP, it's a simple matter to include a language variable on
> each page, and then to echo that variable in the link, e.g.,
>
> $language = 'urdu'
> ....
> <a href="../<?php echo($language); ?>/current-page.php">

In addition, you may find this useful:

echo basename($_SERVER['SCRIPT_NAME']);

That gives you the name of the current page.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
davecheetAuthor
Inspiring
September 22, 2006
Thanks David,

I added the echo basename($_SERVER['SCRIPT_NAME']); lineto a simple text link at the top of the page and it work perfectly first click.

However, it seems to have affected the menu on every page too, making every item in the menu go other language too.
The menu system I used is a project VII Tree Menu Magic set-up which obviously is affected by this piece of code.

Interestingly, after I removed the ($_SERVER['SCRIPT_NAME'] line from the site, the menu continues to function incorrectly.

Do you have any ideas how I can fix the menu and possible a way to isolate the code in question so that it works but doesn't affect anything else?

Thanks for your help though, it's always hugely appreciated.

Cheers

Dave
Inspiring
September 18, 2006
If you are using PHP, it's a simple matter to include a language variable on
each page, and then to echo that variable in the link, e.g.,

$language = 'urdu'
....
<a href="../<?php echo($language); ?>/current-page.php">

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"davecheet" <webforumsuser@macromedia.com> wrote in message
news:eem112$oc5$1@forums.macromedia.com...
> is there a piece of code I can use to include the current page name in a
> link
> to another folde rwhich contains and mirror image of the site structure
> but in
> a different language?
>
> something like this:
>
> <a href="../english/current-page.php">
>
> That way whenever someone clicks on the link they will go to the right
> (same-name) page in whichever language they want. If it's possible I can
> simply
> add this lineto the template that governs each language an dmy job is
> done. If
> it's not possible, I have a long slog ahead of me, typing in each one
> individually.
>
>
> Can anyone help?
>
> Cheers
>
>
> Dave
>
>
>