Jump to content

Creating Sitewide Content


condoravenue

Recommended Posts

Hello, I have recently discovered that you can make sitewide content using the php function get_file_contents(), if you put html code in a separate file. My site's header, navigation, and footer all use this function. This makes changing the layout of your site about 50 times faster, since you only have to edit a couple of files, rather than every single page. Look at my example.

 

The code for each page will look like this, so that I only have to edit the content.

<?php $file = file_get_contents ("header_and_navigation.php"); echo $file;?>
<p>Content goes here.</p>
<?php $file = file_get_contents ("footer.php"); echo $file;?>

 

header_and_navigation.php may look like this:

<html>
<head>
<title>title</title>
</head>
<body>
<div class = "header"><h1>Title</h1></div>
<div class = "navigation"><a href = "home.php>home</a><a href = "about.php>about</a></div>

 

while footer.php may look like this:

<div class = "footer"><a href = "contact.php>contact</a><a href = "terms.php>terms</a></div>
</body>
</html>

 

I thought of this on my own. No one ever suggested I do it this way. This leads me to believe that there must be a downside to it. What do you guys think of it?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.