What's a good way to set your title for each page?
Currently I use a system that is like header, index, footer. The index imports the header at top and footer at the bottom and the header has all the including stuff needed for each page and as well as the <head></head> stuff. The only problem is that I have not really a good idea how I should be able to make something like a forum that has the title of the thread as a title on the current page (like: My site - title of thread).
So how would you do it?
Basic mockup of my current way:
header:
php including and variables created
<html> <head> <title>yay</title> *linking in stylesheets, java etc.* </head> <body>adding stuff that should be on every page
index:
include header
alot of code
include footer
footer:
my footer
</body> </html>About this post
- Posted
- Archived
- Score
- 1 · 100% up
- Kind
- Text
- ID
- cuugg
2 comments
Header should be just your html and stuff, so set a var in your main file (eg, index.php).
index.php:
header.php
In your header, check the value of the postId or whatever you call it in your query string. Then make a trip to the database, retrieve the subject of that post, and drop it in the title tag.