Jump to content
Larry Ullman's Book Forums

Recommended Posts

Assign the page specific content to a variable and check to see if the variable is set within the included file:

$foo = 'content to include here';
include 'header.php';

 

In header/footer include file

if(isset($foo)) {
echo $foo;
}

 

Using if() and isset() makes $foo optional, so you can just set content when you need to.

  • Upvote 1
Link to comment
Share on other sites

Hello,

You should be able to use variables. For instance, here is what I do for the "description" meta tag, and for the CSS files:

 

• In the header:

<meta name="description" content="<?php print $meta_description ?>"

<link rel="stylesheet" type="text/css" href="<?php print BASE_URL.$style ?>" />

 

• Near the top of each page:

$meta_description = "Some description";

$style = 'css/some_file.css';

 

I hope this helps,

  • Upvote 1
Link to comment
Share on other sites

I guess it depends if the meta tags and JS are page-specific, but I imagine you'd want to write like you normally would.

For example, you might have the following PHP:

 

<?php

include(header.html);

// DB connection and content loading here

include(footer.html);

?>

 

And then your footer.html file might look like the following:

 

   <script>

     // JS goes here.

   </script>

 </body>

</html>

 

Does that make sense? Does this answer your question?

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...