• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

include current page name in link address

Participant ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

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

TOPICS
Server side applications

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Oct 06, 2006 Oct 06, 2006
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

Votes

Translate

Translate
LEGEND ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

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


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

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/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 22, 2006 Sep 22, 2006

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 22, 2006 Sep 22, 2006

Copy link to clipboard

Copied

davecheet wrote:
> 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.

If you put this in a page, you'll see exactly what it does:

<?php echo basename($_SERVER['SCRIPT_NAME']); ?>

It simply displays the name of the file. There is no way that putting
that information in a link could affect other pages too.

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

Sounds like a browser cache problem to me.

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 22, 2006 Sep 22, 2006

Copy link to clipboard

Copied

Okay,

I replaced the entire language folder with a back up and immediately the problem was solved. then I recreated the link but this time putting it as an item within the main menu. The same thing happens. Incidentally it happens in every browser I use IE, Safarai, Firefox, AOL; so I guess it can't be a browser issue

I know I can easliy change things so that the language button takes you back to the homepage for each language but that seems a bit of a cop out.

Should I look at adding the code as an include or something like that?

Cheers

Dave

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 22, 2006 Sep 22, 2006

Copy link to clipboard

Copied

Iive just quickly looked at it on 3 other machines and the same happens on each one, so it's not specific to my system either. Wierd.

Cheers

Dave

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 06, 2006 Oct 06, 2006

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 06, 2006 Oct 06, 2006

Copy link to clipboard

Copied

LATEST
davecheet wrote:
> 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.

Glad to hear you finally got it sorted. Often it's a tiny mistake that
causes something to go wrong. Sometimes it's faster to start from
scratch than look for that tiny needle in a haystack.

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

I put a tutorial on my PHP site about how to do this:

Dynamic Link Tutorial

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

I put a tutorial on my PHP site , PHP-Newbie.com, about how to do this:

Dynamic Link Tutorial

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

I put a tutorial on my PHP site , PHP-Newbie.com, about how to do this:

Dynamic Link Tutorial

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

I put a tutorial on my PHP site , PHP-Newbie.com, about how to do this:

Dynamic Link Tutorial

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

I put a tutorial on my PHP site , PHP-Newbie.com, about how to do this:

Dynamic Link Tutorial

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

sorry about all those links. the forum is under maintainance, and i will remove the duplicates as soon as i can get in.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

Don't bother. You cannot remove them.

--
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
==================


"forumnotifier" <webforumsuser@macromedia.com> wrote in message
news:eemkdi$ive$1@forums.macromedia.com...
> sorry about all those links. the forum is under maintainance, and i will
> remove the duplicates as soon as i can get in.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

sorry about the 8 duplicate posts. adobe is having some issues right now.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 18, 2006 Sep 18, 2006

Copy link to clipboard

Copied

You mean as opposed to the standard boring issues they have with the
webforum? 8)

--
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
==================


"digitalus media" <webforumsuser@macromedia.com> wrote in message
news:eempjh$p50$1@forums.macromedia.com...
> sorry about the 8 duplicate posts. adobe is having some issues right now.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines