I like to replicate header/footer content using require_once at the top of my document like so:
<?php require_once( "SNIPPETS/HEADER.php" ); ?>
Where the snippet header.php has everything from my <!DOCTYPE>
and opening <html>
to my page header in the <body>
(navigation, logo, etc.) And I do similar for the footer. It is immensely helpful with updating multipage sites.
I am working on a project for a small company that uses a sales/web platform that is fairly restrictive and does not support PHP, or any server-side scripting. The thing is the website is actually going to be fairly complex and may need revisions, so I want to use this methodology if at all possible.
I am stuck with HTML/CSS/JS. Is there any function or workaround that I can use to do this?
I was thinking I might be able to have an externally hosted snippet db file (xml or json) that I can call and read with js, and then do an innerHTML or outerHTML replacement of the <head></head>
, <div class='header'></div>
, and <footer></footer>
tags.
But that seems maybe a tad inelegant, so I was wondering if anyone else had a similar problem with a better solution?