You are here: PSPad forum > English discussion forum > "Includes" in HTML files?
Posted by: David.Boettcher | Date: 2011-12-31 12: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: 2011-12-31 12:37 | IP: IP Logged
The best way is to use PHP and it's include.
Posted by: carbonize | Date: 2011-12-31 18: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
Posted by: ele | Date: 2015-02-02 17:12 | IP: IP Logged
Although this thread is quite a bit old there may still be people looking for an editor-side include solution.
Such a tool is pageFinalizer. Using a pseudo include tag it will insert html code stored in an external file. For David's copyright issue it has an even simpler solution: define a HTML variable e.g %date%, which will then be replaced with the actual date when you run the tool.
Although pageFinalizer is not a PSPad extension, it can be integrated into PSPad so that you can run it from within PSPad - the manual explains how.
Download: pagefinalizer.diorama.ch
Edited 1 time(s). Last edit at 2015-02-02 17:17 by ele.
Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR