Welcome to WebmasterWorld Guest from 54.226.246.160

Forum Moderators: not2easy

Message Too Old, No Replies

CSS tags to insert same header and footer into multiple pages?

     

nadsab

11:52 pm on Dec 22, 2011 (gmt 0)

10+ Year Member



Hi,

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?

Thanks

Skier88

1:36 am on Dec 23, 2011 (gmt 0)

5+ Year Member



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.

lucy24

1:47 am on Dec 23, 2011 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



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.

tvirus

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

rocknbil

5:20 pm on Dec 23, 2011 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.

tvirus

6:23 pm on Dec 23, 2011 (gmt 0)



I stand corrected.

lucy24

12:05 am on Dec 24, 2011 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



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 ::

mack

3:45 am on Dec 24, 2011 (gmt 0)

WebmasterWorld Administrator mack is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.

Mack.

rocknbil

6:14 pm on Dec 24, 2011 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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. :-)
 

Featured Threads

Hot Threads This Week

Hot Threads This Month