You are here: PSPad forum > English discussion forum > "Includes" in HTML files?
Posted by: David.Boettcher | Date: 12/31/2011 13:15 | IP: IP Logged
What is the best way to deal with repeated blocks of code?
I find that I use some bits of code over and over, like a copyright message at the foot of every page. Copying and pasting between pages is OK, but if I need to make a change e.g. to the copyright dates, then I need to change every page. I can take the code out and make it a server-side include, but this seems like an overkill for such a simple problem.
What I would like is something like a server side include but in the editor, so that when I save the file the HTML code output would have the external code included in it, but the external code is not shown in the editor, just a tag to show where it is to be included. This would mean that the edited file would not be the same as the HTML file, but would need to be some sort of psuedo-html file with the same name.
Does this make any sense? Is anything like it possible?
Posted by: pspad | Date: 12/31/2011 13:37 | IP: IP Logged
The best way is to use PHP and it's include.
Posted by: carbonize | Date: 12/31/2011 19:07 | IP: IP Logged
As Jan said PHP include is the easiest way. If the file to be included is in the flder you can just use something like
<?php
include('footer.html');
?>
Doesn't have to be .html can be any extension even txt.
--
Carbonize
Editor PSPad - freeware editor, © 2001 - 2013 Jan Fiala
Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák