Click to See Complete Forum and Search --> : css vs frame/iframe
Siddan
12-27-2004, 09:35 PM
I know many of you always say that css is preferable over frames when building sites....
what I donīt get though is when having the menu in lots of pages.. letīs say almost 100 pages and you have it in css on the left side.
What if you want to change or add one menu row? would you then have to edit all the 100 pages to add that new change ?
I so far personally prefer having an iframe line on every page which is easy to change, and with dreamweaver at least I can search and replace if I want to change the width or something in the future.
just a thought I havent been able to lurke out
Jupac
12-27-2004, 09:50 PM
You forgot to
Import the css for a .css file
<style type="text/css">
@import "style.css";
</style>
Siddan
12-27-2004, 10:12 PM
hmm, second time I see that... first time was about an hour ago in a compatible table page in one of the links in here...
so what does it mean and how does it work and.... what does it do actually if not just importing :)
thanks for the fast reply tho...but I will head off to sleep now so it is not needed to rush with an answer hehe
Jupac
12-27-2004, 10:15 PM
OK, right now you have like
<style type="text/css">
blah{
}
blah{
}
</style>
On each page. so you have to go thorugh each one and change.
but now you use
<style type="text/css">
@import "style.css";
</style>
SO that you only chage one file and all of your pages will have the same change. This will also save a lot of bandwidth
Siddan
12-27-2004, 11:00 PM
ahh couldnīt sleep of all the interesting posts in here so I had a quick look here and saw that you replied once again :)
well
I am actually allready using a bit of the external .css so I donīt have at all the same styles written repeatedly in every page.... only some but not much at all.
But yes I can understand how easy it is to alter the styls and alignments and such... but what if I want to add an extra link to the menu.
On my page for an example I use 5 images as for the site main link navigation and when I would like to add an extra image to link to a totally new site... how would I do to make all the rest of the pages to take the affect of the change by editing 1 page only.. or only the 1 style sheet page, that is my main concern.
Cus now I use iframe as for the top navigation. And when I want to edit the menu... I just edit the one single page
....
Perhaps if there could be a new linking that works the same as iframe but using pure css instead... that I could understand but not sure if there is any solution like.... so?
Jupac
12-27-2004, 11:39 PM
ohh just inculde it useing some type of server-side script
<?php
include("link.php");
?>
Siddan
12-27-2004, 11:59 PM
aahh, well see, thatīs where it is dead end for me then. Not really sure how to handle phps and sever side clentes... so I am stuck with regular htm+css for a while longer :)
*yawns* now it is really time for bed,,, thanks for the convo
Jaelan
12-28-2004, 11:01 AM
It's not really that hard.
Just place this line instead of the link html you have on all of your pages...
<?php
include("link.php");
?>
Then, create a file called link.php in the same directory as your index.* file(or in subsequent, as long as you change the include to reflect the path to the link.php file.
Then, just copy your link HTML that you currently have and paste it in the new link.php file. No special code needed.
Any time you need to change your link code, just change it in link.php and bam! all 100 or however many pages that include that link.php file are changed.
It's similar to using external stylesheets, except you're using an external link page.
A few points. To use the php code above, you must:
1) make sure your webserver (whoever's hosting your domain) has php configured for apache.
2) change all pages that use the above include statement to *.php, instead of *.htm(l)
Hope that clears things up some.
Jaelan
duderdude2
12-28-2004, 01:43 PM
Jaelan, one question, what's the difference between using .php to say, .txt for the include file (what is what I'm doing)?
Jaelan
12-28-2004, 03:36 PM
There's no difference, if you're doing straight html. But, if you were to have php in your link section, I don't think it would work in a .txt, .html, etc. I might be wrong, cause I've never tried it. Personally, I use .inc for stuff like that :)
Jaelan
Siddan
12-28-2004, 04:15 PM
aha yea yea,, so this
<?php
include("link.php");
?>
will work just like the iframe,,, except in the source code it will looke like as if the link page doesnīt exist and the code seems to be written repeatedly on every page?
Jaelan
12-28-2004, 04:20 PM
I don't know if it works exactly as an iframe, as I've never used 'em :)
But what it allows you to do is edit your links in one place only and have it change for all pages that include that file. However, the source code will still show up...
Siddan
12-28-2004, 05:14 PM
the technique is the same as with iframe ... I just have one htm page for the menu which is linked inside every
but but,, I just tried converting every page to php and replaced the iframe tag with the php iclude and there is error...
when I view it in dreamweaver I can only see the menu and </HEAD> is displayed in yellow background as if it is wrongly placed. When I preview it in browser it shows all fine but not when I click on the menu link to go to another page cus then the menu disappears.
SO now I have uploaded all the pages and it displayes as it should
but quite disturbing when I cant view them in dreamweaver
.....
SO i guess I have to convert my pages to pure css or something, what program is the best to edit css kind of pages really?
Jaelan
12-28-2004, 05:16 PM
dreamweaver doesn't like php...heh that's one of the problems w/ it and why I stick to text-editing :D
Siddan
12-28-2004, 05:34 PM
then I assume you are using a server client on your computer of somekind to be able to preview your site/page before you upload it?...
I cannot open the php pages locally on my computer ... perhaps cus I have dreamweaver installed...
Jaelan
12-28-2004, 05:37 PM
I think what's actually happening is your local machine doesn't have php running on it (which is why dreamweaver won't let you preview it). But I'm not certain, as I don't use it.
I have a test server at my company that has php running, so I upload it to there, test it out, then when it's finished, move it to "live" server...
Jaelan
Siddan
12-28-2004, 05:51 PM
yea, thatīs how it is normally done at pro sites :)
David Harrison
12-28-2004, 11:27 PM
Well, I don't use PHP, I use ASP but that's beside the point really as it's just another server-side language. If I wanted to preview my code before I uploaded it I would need to get IIS running on my machine. However I don't bother with any of that.
I just write the code, FTP it, refresh my browser and see if it worked or not. I've got a pretty decent connection though so I don't really have to wait for it to finish uploading because by the time I've lifted my finger off the mouse button, it's done.
So, to clear up all this stuff about includes, let's say you've got two files.
index.asp:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>BlankH</title>
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<style type="text/css"><!--
@import "myStyles.css";
--></style>
</head>
<body>
<!--#include file="someContent.inc"-->
</body>
</html>
someContent.inc:<p>
<a href="http://www.w3.org/">The W3C!</a>
</p>
The HTML sent to the browser (ie: what you would see if you were to view the source) would be this:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>BlankH</title>
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<style type="text/css"><!--
@import "myStyles.css";
--></style>
</head>
<body>
<p>
<a href="http://www.w3.org/">The W3C!</a>
</p>
</body>
</html>And that's all there is to it. Incase you're wondering why I've got an HTML comment in the middle of index.asp, that's just the way including files works with ASP. As you've already seen, with PHP it's slightly different.
Siddan
12-29-2004, 08:14 AM
thanks,, but will this work with an already php server?
David Harrison
12-29-2004, 08:29 AM
Yes of course, but as I said:Originally posted by lavalamp
that's just the way including files works with ASP. As you've already seen, with PHP it's slightly different.
Siddan
12-29-2004, 04:08 PM
thatīs the word which made me wonder... "works with asp",,, as if it just works with asp :p