PDA

View Full Version : Using CSS to place the same text on every page?


Jittor
01-30-2006, 04:25 PM
Hello all,

I am learning CSS and am really starting to like some of the things I can do with it. I have a website that has a footer at the bottom of every page. Well, I made the site a long long time ago before I knew how to make templates and so on. I now have to change the copyright date on the footer for every page. I know now that this will be a consistent problem if I don't learn how to do this in a more efficient way. Is there a way I can link a style sheet to all these pages and add the footer at the bottom all of them. That way next time I can just change the copyright date on the style sheet and not on every page. Is this do able? Thanks! :)

desertdirk
01-30-2006, 04:50 PM
You can use an include file that has the information in it for the footer. Then you add an include statement on each page which refrences the include file.

the include file is named like "footer.inc" and looks something like this


<p align="center" class="style1">Web design and hosting by My Web Service (http://www.yourdomainname.com) &copy;2004</p>


</p>
</body>
</html>

notice at the bottom the closing body and html tags. When the include file is loaded, it completes the page by using the closing tags. You would have to remove the body and html tags from each page you add the include page to. But once it is set up, you only have to change one line in one file.

If you are using php you can put in a little code like

&copy; 2004- <?php echo date(Y); ?>

that way the copyright will always be from the first year (2004) to the current year
dd

Jittor
01-30-2006, 05:09 PM
How do I set up an include file and when you say add an include statement on each page is that like <div id="footer.inc"> or am I just way off? I don't think I have done this before. I'm still a beginner at CSS.

Jittor
01-30-2006, 05:44 PM
I think I figured it out. It's like linking to another html page. Lets see if this is correct.

I added

</p> where I wanted the footer to be.

In another html document (within DW) I put your text in from above to test. <p align="center" class="style1">Web design and hosting by My Web Service (http://www.yourdomainname.com) &copy;2004</p> and saved it as a footer.inc, which made it a basic text file. It is my understanding I can do this with most other file types like php and asp and so on.

domedia
01-30-2006, 05:49 PM
CSS and PHP are two very different things.
CSS only styles your content, you cannot add any content or dynamically change your content with CSS.
PHP is a server side language, which you run on the server before it's sent to the browser (client-side)

If you have a regular page (with php extension) you can include an external file like this: <?php include("copy.inc"); ?>
Then all you need to do is create a file with that name and extension and you're good. and don't forget to use Dirks little snippet above in copy.inc, so the copyright years updates automatically every year.

Jittor
01-30-2006, 06:05 PM
Thanks Dom,

I don't know what I was thinking. I knew that CSS couldn't do that-duh. I was confusing myself. I am not using php just simple html but I still linked it, like a style sheet, so I could change all pages at one time. I wish I could use php for this but I don't know php.......yet!

Jittor
01-30-2006, 06:32 PM
Is this the right way to link my file?


When I preview the file the text footer is there but when I post it to the ftp it doesn't show up. i don't understand why - any ideas?

this is the code for the footer.inc file



<font size="1" face="Arial, Helvetica, sans-serif">Copyright &copy; 2005 FMB, LLC and its Licensors.

All rights reserved. Executive Producer: Client </font> </p>

I didn't add the </body> or the </html> tag because it is not the very last thing on the page. there are some bars below the footer.

domedia
01-30-2006, 06:42 PM
If your hot supports php use my code above.

Jittor
01-30-2006, 06:53 PM
It doesn't, sorry

Creative Insanity
01-30-2006, 07:02 PM
No php support ah.
Then I would be making a template and connecting your pages to that template before things get too far out of hand.

Jittor
01-30-2006, 07:18 PM
Hey the boss like to go cheap. that sounds like a great start. That way I only have to update the 1 file. I just don't understand why my link to my footer.inc file within my html page didn't work. Did I miss a step or something?

desertdirk
01-31-2006, 12:40 AM
Jittor
sorry, - you were asking CSS and I went right to PHP. Sorry for the confusion.
I don't know if you can do it that way in CSS. But as CI says, maybe templates are the way to go
dd

dthomsen8
02-06-2006, 02:37 PM
PHP support by web hosting companies is very common and even some of the cheapest companies support it. If your boss will go for it, look around for a hosting company that is just as cheap or cheaper, and does support PHP.

If you need help looking for a hosting company, I am sure that posting a new thread here will provide you with ideas.

Hey the boss like to go cheap. that sounds like a great start. That way I only have to update the 1 file. I just don't understand why my link to my footer.inc file within my html page didn't work. Did I miss a step or something?