| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
dt immigrant
|
Change content with link. How?
My PHP knowledge is very limited, so please help. I have a simple website done with some PHP (that is require_once, as that's pretty much all that I know). My problem is that I have to create an English version as well so I need to be able to change somehow the content of the page with a link, without leaving that page. That is if I am on the some-page.php page and want to switch to the English version I don't have to go back to the index_en.php page but still remain on some-page.php?somePHPmumboJumbo-content=en Help. |
|
|
|
|
|
#2 (permalink) |
|
Senior Member
Join Date: Feb 2004
Location: Exeter
Posts: 773
|
In its simplest form: Code:
|
|
|
|
#4 (permalink) | |
|
Senior Member
Join Date: Feb 2004
Location: Exeter
Posts: 773
|
Quote:
Thats what its doing, telling the browser which content to load, based on the link that has been clicked. $content is just a variable that stores the "on/off" state. Just put your relevant content inside the if statement. Code:
|
|
|
|
|
#6 (permalink) |
|
Rough Creep Arse™
|
$content is a variable that stores the value of parameter passed in the URL - blah.php?content=off. So you can then use this to display one language content or another So like - with your url, some-page.php?somePHPmumboJumbo-content=en Code:
|
|
|
|
#7 (permalink) |
|
dt immigrant
|
Thanks I reckon it'd be easier if i asked any of the programmers at work to do it for me, but I guess I'll never learn that way, huh? I'm still struggling with it at the moment... My current problem is, once the default content is loaded, do I need to refresh the page to change the main content? If so, how do I do this wizardry? |
|
|
|
#8 (permalink) |
|
Rough Creep Arse™
|
Yes, you would. But then, the user would click on a link - language: <a href="some-page.php?somePHPmumboJumbo-content=en">english</a> | < href="some-page.php?somePHPmumboJumbo-content=fr">french</a> or a drop down menu with an onchange="submit()" kind of thing going on. |
|
|
|
#10 (permalink) | |
|
Senior Member
Join Date: Feb 2004
Location: Exeter
Posts: 773
|
Quote:
You can do that with the method that I showed you. Sorry, I don't know how to explain it any simpler (not supposed to sound patronising) |
|
|
|
|
#12 (permalink) |
|
say werd.
Join Date: Oct 2004
Location: Japan
Posts: 1,297
|
Basically I'm saying the same thing as Joe and Transmogrify, but hey... The point is you're loading the same page, but changing the variable (and thus the content) with the link. whatever.php might be the default page. If you include a link on this page to whatever.php?language=en and it's clicked, you'll be loading the same page, but also including whatever content you've written in the if statement ie: Code:
So when you reload whatever.php as whatever.php?language=en, "Hello..." will be displayed. If you provide a link <a href="whatever.php?language=fr>Change to French</a>, then when a user clicks that link the page will be reloaded, the variable language will equal 'fr' (which is french) and thus "Bonjour..." will be displayed. Comprendre? |
|
|
|
#13 (permalink) |
|
dt immigrant
|
Thanks, I understood so far. I need to find a way to implement it in my actual system of includes, whithout going through too much trouble. (I'm tackling this thing the lazy way, I know I'll keep you guys posted on my failures Thank you very much for all the help |
|
|
|
#16 (permalink) |
|
dt immigrant
|
Okey, more details PHP Code:
These variables are defined in the top of the page In the div with the switching content I put this PHP Code:
What I'd like to know is if there is a way to have those variables include some files which I already created. That's why I don't want to put everything in this page... Another question would be how do I go about including some default text. I mean if I enter in the browser instead of page.php?content=en just page.php nothing loads up (obviously) Thanks |
|
|
|
#17 (permalink) | |
|
dt immigrant
|
Quote:
fixed. added an else statement, after the else if one. still working on the other problem I mentioned |
|
|
|
|
#19 (permalink) |
|
Registered User
Join Date: Jul 2005
Location: Staffordshire, England
Posts: 24
|
I've built a nice little tool... if u go on my web site http://www.outsourcedstudios.com and pop me an email, i'll send you a copy... uses PHP btw. I cant put it here as its multiple pages (very simple tho). =D |
|
![]() |