PDA

View Full Version : hehehe wierd question in php


TheGreatOne
06-10-03, 09:09 AM
Right in my php site i do it by using one template file.

index.php?dir=XXXXXXXXX&page=home

What ever the $dir is and $page is dertermines what page it includes and what directory from. Simple really :)

Right i go board when working so i had to go to intergrate babelfish. Now i cant use it like a normal site due to i have a large nav so i changed to a java one. Right soooo what i did was config it so i have

index.php?dir=challengesimon&page=home&lang=en_de

The way i coded it, it worked and it changed the included file languge. Brillaint :D

Now from saving me doing 5 other .php files with one in french.php one german.php etc can I do it so no matter what link someone clicks in the nav. So like they clicked index.php?dir=downloads&page=home and they are on the page index.php?dir=tips&page=who&lang=en_de . It changes pages to the link they keeped yet still it keeps the lang=en_de on the new url.

Cause like different languges have different exstentions..

lang=en_de
lang=en_sp
lang=en_fr
lang=en_jp

Understand??? :D

Cheers and hope you understand hehehehe

phpkid
06-10-03, 03:25 PM
And your problem is..


...I didn't really understand...

Regards,
JD

amailer
06-10-03, 03:45 PM
could you show us the site you are having this problem [ which i do not understand either ] and then the code?

Pearl
06-10-03, 04:01 PM
I'm not a PHP coder, only Perl... but I *think* I get what you mean. When your visitor chooses a particular language, you want that language preference to stay the same no matter where they venture on your site.. is this right?

Depending on your script....
* try using cookies to remember their preferences
* hard code the default language as "en_de" or whichever you prefer, when no language is selected.
* internally code your script to replace all the links (eek!) probably the slowest choices of them all... but like I said, it depends on your script and how you're pulling your pages.

A more precise explanation on what you are trying to accomplish might help you get the right solution from some of the PHP experts here.

Best of Luck!

TheGreatOne
06-10-03, 04:08 PM
Sorry my grammer skills are a little poor :( > Yea thats the one Pearl. Wants it to stay with the users. My Coding is not tooo strong so someone may have to give me a hand :p. The default language is already there on the page :)

amailer
06-10-03, 04:13 PM
anyway, if you could post your code maby we coudl change it and make it work, and yes i do like dance! z103.5 RADIO! :)

__________________
## Like Dance Music ?? ##

TheGreatOne
06-10-03, 04:18 PM
<?php

$dir = $dir ? $dir : "";
$page = $page ? $page : "home";
$lang = $lang ? $lang : "en_fr";

$error = 0;
if (file_exists("content/$dir/$page.php"))
include "http://babelfish.altavista.com/babelfish/urltrurl?tt=url&url=**URL**/$dir/$page.php&lp=$lang";
else
$error = 1;

?>
<?php

if ($error)
echo "Error HTML Code";

?>

I dont like giving out my site code just incase some little bugger in the same community uses it :p

The Wolf
06-11-03, 12:30 AM
You could use str_replace to replace all referances to index.php with : 'index.php?lang=*'.