Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

WillMaster > LibraryWebsite Development and Maintenance

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Central Content File for Many Sites

As an owner of multiple websites, you undoubtedly have had to make the same page edit on each site. Perhaps there was a telephone number change or a we-are-on-vacation notice.

It is possible to update one central file with all websites updating themselves automatically. It's an efficient way to do things.

With the ease of implementation described in this article, you may decide to add some intermittently-changing information to pages at your various websites. When the information changes, only one file needs to be updated.

The information might be (as examples):

  • Local weather.

  • Information with link about your latest blog post.

  • Special menu links. (We use it for this. You'll see them in the right-hand column of the Blog and Library pages.)

  • Local ads. (We use it for this. As of this writing, it's an ad for 52 Good-to-Know Techbits.)

  • Project progress notes.

  • Contact information.

What You Do

Implementation is two steps:

  1. Make a file with the content and note its URL.

  2. Insert a line of PHP code on pages where the content is to be published.

Step 1.

Make one text file of the information to be inserted into web pages at your various sites.

The content needs to be HTML formatted. It may contain images, a form, a video, virtually anything that can be published on a web page.

Upload the file to one of your websites. (This will be the central file you update to change all web pages where the information is published.)

The uploaded file name can have any valid web page file name extension. If it has PHP code, .php should be the extension.

Make a note of the uploaded file's URL.

Step 2.

Insert this line of PHP code in the web pages where the content in step 1 is to be published (customization note follows):

<?php echo(file_get_contents('http://example.com/page.php')); ?>

Customization:

Replace the http://example.com/page.php URL with the URL of the file you uploaded in step 1.

Wherever the above PHP code is inserted, the content of step 1 is published …

… with one caveat. The PHP configuration on the server with the domain that is pulling in the content must allow URLs to be used in the file_get_contents() function. (Technical allow_url_fopen details.)

If you're unsure whether or not the PHP configuration on your site allows URLs to be used in the file_get_contents() function, test the PHP code on a temporary web page. Most do. But if yours doesn't, Ajax can be used. It would be more complicated to implement and it's outside the scope of this article. But it's noted to inform that there is a way.

Having only one central file to update to affect the content of numerous locations is a good thing.

You save time. And you eliminate all chance of forgetting the locations of all those pages that need updating.

As a bonus, the system is easy to implement.

(This article first appeared in Possibilities newsletter.)

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC