|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Inserting HTML Into A Page?
Hi all,
I have a problem, and I'm wondering if there's a practical solution to it... I want to insert an HTML page into an existing HTML page. I want to insert a list of recent article links into every page of my website, without having to cut and paste the code directly onto every page, every single week. Is there a way to tell my pages to insert a block of HTML code from an "article links" file? The only idea I have is that I could code the HTML links code into a PHP file, and then get my pages to call run PHP file everytime a page is loaded. But I have no idea what function I would use. Any suggestions? |
|
#2
|
||||
|
||||
|
If your server supports PHP, the easiest solution would be to create a separate file. Name the file something like 'links.htm' and paste in the HTML code you want on every page.
On the main page, use <?php include('links.htm'); ?> to include the external file. Make sure your main page is named .php so your server will run it through the PHP interpretor. You might find PHP's documentation of include() helpful.
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter! DevArticles Forum Moderator "The net is a waste of time, and that's exactly what's right about it." -- William Gibson |
|
#3
|
|||
|
|||
|
Quote:
Are you saying my main page should then be index.php? If I want to insert this code on every page in my website, would that also mean that every page would have to be a .php? If so, I'm not sure I can work with that. Is there any other way? Is there a way where I can keep the .html, but still use php within it to do what I want? |
|
#4
|
||||
|
||||
|
Quote:
Code:
<FilesMatch "^index.html$"> ForceType application/x-httpd-php </FilesMatch> If used properly, there will be next to no code duplication with php. Last edited by Humanetainit : March 1st, 2007 at 05:29 AM. |
|
#5
|
|||
|
|||
|
Quote:
Are there any other ways without using PHP? |
|
#6
|
||||
|
||||
|
Yes, Server Side Includes, but your server has to support them.
Code:
<!--#include virtual="articlelinks.html" --> |
|
#7
|
|||
|
|||
|
Quote:
Thanks a million! So simple, and it works for me. |
|
#8
|
||||
|
||||
|
You're quite welcome!
|
![]() |
| Viewing: Dev Articles Community Forums > Web Design > Advanced Web Development > Inserting HTML Into A Page? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|