Help with PHP includes and passing variables

Confused

Elite Member
Nov 13, 2000
14,166
0
0
Hi all,

This is my first step into creating a web page with PHP, and I've just got one little problem that I'd like to try to address :)

I've got the main page (main.php) which I'm trying to use to show all the other pages, so that any layout or design changes (that exist outside of CSS modifications) can be done without having to modify the content pages, they will be as plain as possible.

The biggest problem I'm having is trying to set the page Title dynamically for each individual content page. The only way I've been able to do this so far is to include the header from the relevent content page, but that isn't ideal as I can't just point a browser to /pages/page.php and get a content-only version of the page (like I've seen some other sites do).

I'm also helping out someone else at work with designing a similar site, after he saw my layout/design, but want to get these problems sorted out.

Attached is the current code, and modifications that could be made will be greatly appreciated :)


Thanks in advance :)
 

Confused

Elite Member
Nov 13, 2000
14,166
0
0
Bump, anyone else got any more ideas, I'm sure it's something simple :)


Garry
 

Modeps

Lifer
Oct 24, 2000
17,254
44
91
I assume you're passing a variable to determine what content page you will show, correct? How about, based on that variable, you display a different title? So in the header of the 'shell' page you just have a long 'if' statement that you can also use to determine which page to include:
 

Confused

Elite Member
Nov 13, 2000
14,166
0
0
Yeah, I am passing variables to say which page to display.

However, I was trying (if possible) to get away from a huge If statement in the header, but if that's the only way around it then it's the only way around it.
 

Modeps

Lifer
Oct 24, 2000
17,254
44
91
Of course, if you're using a mysql database, you could store the page names and content in there instead of having to do it through includes... then you'd just have to write a quick query to pull all the info out of the db.
 

Confused

Elite Member
Nov 13, 2000
14,166
0
0
Yeah, that might be the next stage, but I'm only just learning PHP and CSS/HTML, so MySQL is alien to me ;) But i suppose it's a logical step! ;)


Garry