Skip to main content
Known Participant
January 3, 2010
Question

Instead of using headers/footers in php, can I...

  • January 3, 2010
  • 6 replies
  • 837 views

Hi,

Currently, I am using PHP includes to assemble my page elements together. The header gets its own include, the content, and the footer.

Only problem with this scenario is that things opened in the header -- like tables, for instance -- aren't closed until the footer. As you might imagine, this makes editing the header OR footer a very daunting process.

Would it, instead, be possible to fetch -- as an include -- the entire site template... and specify somewhere inside where the content will be included? This way, when I need to modify the template, it'll hold up together in front of me as I am working on it (and not just contain opening elements that are never closed, or vice versa).

This topic is closed to new replies. Start a new post to keep the conversation going.

6 replies

Ken_Ford_-_ACP-QFo4AB
Inspiring
January 3, 2010

Sure, like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Page</title>
</head>
<body>
<?php include('header.php'); ?>
<?php include('content.php'); ?>
<?php include('footer.php'); ?>
</body>
</html>

Ken Ford

jyeager11Author
Known Participant
January 3, 2010

Actually, you just described word-for-word how I'm already doing it (see first paragraph of the OP).

If you read the rest of the OP more closely, you'll see that you didn't really understand what it is I'm asking (or I wasn't as clear as I thought I was).

"Header" opens elements that aren't closed until "footer". As such, header isn't editable in any practical way inside Dreamweaver (tables get opened but never closed, for instance).

I proposed having the whole template in a single file (so what's opened get closed), with an insert telling the template where the editable area is.

Kind of like how Dreamweaver uses Templates right now, but using PHP so the actual template code is stored only in 1 file, and would require only a single upload after editing.

Ken_Ford_-_ACP-QFo4AB
Inspiring
January 3, 2010

You would just have to set up the page to do what you want.

Without seeing any code, I really can't help, sorry.

Ken Ford