CSS tags to insert same header and footer into multiple pages?
11:52 pm on Dec 22, 2011 (gmt 0)
I forgot the syntax or tags for this, what tags do I use to create and edit just one master page with headers and footers on it, so that I can just edit that one page and have all my changes to headers and footers appear on multiple pages across the site?
1:36 am on Dec 23, 2011 (gmt 0)
Technically you can use :before and :after, but that's a bad idea for a number of good reasons. The "correct" solution would be some form of server-side scripting, like PHP.
1:47 am on Dec 23, 2011 (gmt 0)
Yes, I think "before" and "after" were really intended for things like quotation marks or brackets.
That's assuming you are asking about headers and footers with actual text content. If it's just a background image, then of course you can easily put that in your CSS.
4:28 am on Dec 23, 2011 (gmt 0)
i think what you are aksing doesn't happens with CSS. the :before , :after can only help elements. You can create a header.htm and footer.htm and then you can use server-side include to do the job
PHP <? include 'header.htm'; ?>
HTML <!--#include file="header.html" -->
Remember, this won't work offline on your PC. run it on some server. Try WAMP server for windows
5:20 pm on Dec 23, 2011 (gmt 0)
Slight correction - SSI's will only work if you add .html and/or .htm for parsing html files. By default, only .shtml files are parsed with SSI. details in post #4383542 [webmasterworld.com].
Use file if the include is in the same directory, virtual if it's in some other directory than the current directory.
6:23 pm on Dec 23, 2011 (gmt 0)
I stand corrected.
12:05 am on Dec 24, 2011 (gmt 0)
Way cool :) In the linked thread you said ".htaccess". Does that mean you can reasonably expect it to work if you're on shared hosting?
:: still looking for an idiot-level include that you can pass a variable or two, so it will make a different footer (such as a page-specific menu in a consistent format) for each page ::
3:45 am on Dec 24, 2011 (gmt 0)
Htaccess should generaly work on shared hosting, best bet is to ask your host if its something they allow.
I think a server side language is still the best way to go about it. Php includes would be perfect for your situation.
6:14 pm on Dec 24, 2011 (gmt 0)
If your shared host doesn't allow basic .htaccess directives, it's time for another host! :-)
Php includes would be perfect for your situation.
It will work, but I wouldn't say perfect. PHP is a rich server side scripting language, to use it just for basic includes is overkill. Additionally, you have to mod the server to parse all .html/.htm files as PHP, which can give you some unexpected results - or change your files to .php extensions, which means you have to address SEO issues for existing pages (i.e., all your URLs have now changed and you need to 301 the old ones.)
so it will make a different footer (such as a page-specific menu in a consistent format) for each page
No code samples handy, but yes you can do this, and can even reflect "the current page" via environment variables. An easy way to do the first is just change the directive to point to different footers.
Parsing html as SSI has a lower overhead and it's the right tool for the job - not perfect either, but closer. :-)