How can I use common code on multiple web pages?
I have about 20 html pages that will all share some common html coding. The common elements will be changed and updated frequently.
Is there an easy way to have 1 document that contains the common code that is used by all 20 pages so I don't need to updated all of the pages each time?
Also, I want to stay away from frames.
try this using php:
save the common code in a temp.php and include it wherever you need in your webpage using the include command
As I understand ,
The best solution to your problem is using php.
Just separate header,sidebars,mainbody,and footer section in different pages...
and put it in the pages by using include_once or require_once command.
We are using this process in all our projects and it can be implemented easily and successfully..
Best OF LUck
a historical note:
Long time ago (before PHP and other scripting languages became popular), people used M4 macro processor to include common elements into HTML pages. A nice article describing the process:
Thanks for the replies. I'll check out these methods and try them on my website.
Nikiitea was right but he didn't explain it. Here's a quick explanation:
Step 1. Rename all your .html pages to .php
Step 2. Open notepad and paste the common html into a document.
Step 3. Save the common html document as your_title.php
Step 4. Open the 20 HTML pages and paste this code in the spot where you want the common code to appear:
<?PHP include("http://yourwebsiteurl.com/your_title.php"); ?>
Now when you make changes to the your_title.php file, it will update all your pages.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)