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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...