View Full Version : CSS and external files
HansR
Wed., Mar. 16, 2005, 9:33 am
I?m fairly new to CSS and have yet to launch a page implementing them. However, I have spent some time working with dummy pages and am duly impressed. Most beneficial to me was Jack Wolfgang?s link to Listamatic. (http://css.maxdesign.com.au/listamatic/)
This leads me to propose this common scenario: Assume your homepage links to four pages (i.e, red, blue, green, brown). Each of those pages link to several sub-pages. Every page is expected to link to every other page in its category. Obviously, these links will mirror each other, as the red page and all of the red sub-pages will contain the same links. As will the blue and all blue sub-pages, etc.
Once the site is established, a decision is made to add (or remove) a sub-page from the green section. Currently, I?ll have to add a link to each and every green page. Is there a good way to store the information so all links are generated from a single source? Frames, if I used them, would work. An external .JS file would do it too, but I am hesitant to use script for something as crucial as navigation. Can an .ASP generate this type of code? Is there a better way?
Any thoughts?
Thanks!
HansR
JackWolfgang
Wed., Mar. 16, 2005, 11:44 am
Server-side includes (either as a function of the server, like the include command on Apache or with scripting like PHP) are wonderful for the task of navigation links and menus.
HansR
Thu., Mar. 17, 2005, 3:58 pm
Thanks, Jack. Is there a term for this "list of links", to make my search for resources easier?
JackWolfgang
Thu., Mar. 17, 2005, 10:39 pm
Hans,
PHP is on the web at http://www.php.net
Apache server information is available at http://httpd.apache.org/
But you will want to use the "What's that site running?" tool (http://www.netcraft.com/whats) at Netcraft.com to find out what your server uses (Apache with what mods, IIS, etc.)
HansR
Fri., Mar. 18, 2005, 9:08 am
Thanks! Jack
David Gillaspey
Sat., Mar. 19, 2005, 5:08 pm
Hi Hans,
I concur with Jack regarding server side includes, which in my case are PHP includes. The code is simple. I insert code like this near the top (but after the <body> tag) of all my pages:
<?php
include("includes/sidebar_links.php");
?>
(I would have been smarter to use an absolute file reference, that is,
<?php
http://www.greatchurchwebsites.org/includes/sidebar_links.php
?>
however.)
so if I need to change the links in the lefthand column on all my pages (except, obviously, for this forum), I just change the include file and all pages on my site are updated at once.
Actually, I use three includes (= code in file + file to be inserted) to handle the top and left sides of all my pages, except for forum pages. One include inserts the Question of the Week, the banner, and the navigational links across the top of all pages. The include code goes below the <body> tag, but before the one I mentioned above. (So the order of includes does matter.)
The other include (of the three) is inserted in all my pages in the header area, and contains meta description and keywords data.
I have two includes in the bottom of all my pages. One inserts the modify date plus privacy notification, and the other handles the righthand side of pages. The latter doesn't contain much: just some closing inner table tags; the righthand vertical rule; and closing outer table tags, </body> and </html> tags.
Within the body of my pages, I use includes for my name and email link (all pages) and for such things as inserting how many church websites I've reviewed to date (two or three pages). The latter PHP include points to a file that contains nothing more than a single number. But when I update this file with a new number, it's updated everywhere on my site. I like that.
Use of PHP includes assumes, of course, that you have access to PHP. I think I'm correct in saying that if your hosting company is, or you yourself are, using Apache web server software on a Linux box, you can pretty much be sure that PHP is available to you. If your hoster is using Windows machines, that likely is not the case. You'll have to use ASP.
Using PHP requires your pages have the .php extension rather than the usual .htm or .html extension. PHP pages can contain and usually do contain a mix of HTML and PHP code, however. If fact, it doesn't hurt for a page comprised of nothing but HTML code to have an extension of .php. It is rendered by the PHP server as an HTML page just fine.
The main problem I had with using an PHP include was getting it to actually work the first time. The include files themselves can't contain the usual HTML header and body tags. Moreover, I think such things as extra lines at the top or bottom made the include not work for me. So now when I need a new include file, I don't start from scratch. I make a copy of an existing file and put in the new content I need.
Anyway, as you can see, I love includes.
PHP, by the way, is a server-side programming language. What that means for users is that no one can see your code by viewing the source code of your pages once they're rendered in a browser. I kind of like that. Also, since all the code (and there can be LOTS of code) gets rendered by the PHP server, what actually gets sent to clients (people's browsers) is relatively small and lightweight (= faster download).
Javascript, by contrast, is client-side code, which means all your Javascript is plainly visible, for good or bad, to anyone viewing your source code. Since the code is present in the pages, it makes them slightly bigger than they would be otherwise, too.
That's not to say one shouldn't use Javascript. I'm just pointing out an advantage of using a server-side language like PHP. Some things you want to do with scripting required a client-side programming language.
Sincerely,
David Gillaspey
President
Great Church Websites
JackWolfgang
Sun., Mar. 20, 2005, 12:58 am
Your includes can use a relative reference if the include files are in a directory off the root level (\includes\ for example).
HansR
Mon., Mar. 21, 2005, 1:34 pm
Javascript, by contrast, is client-side code, which means all your Javascript is plainly visible, for good or bad, to anyone viewing your source code. Since the code is present in the pages, it makes them slightly bigger than they would be otherwise, too.
I shy away from .JS because users have the option of disabling it. Depending on what the script is doing, the potential exists for a non-technical user to inadvertently prevent themselves from the ability to access the page. Because server-side script is rendered before it gets to the user, it will work regardless of how their browser is configured.
David Gillaspey
Mon., Mar. 21, 2005, 3:34 pm
Because server-side script is rendered before it gets to the user, it will work regardless of how their browser is configured.
Moreover, depending upon one's browser and computing platform (Mac or PC), sometimes links relying on Javascript to work simply don't work. That's a problem I have with Godaddy (www.godaddy.com, my domain registrar of choice), right now. I can't use I.E. on the Mac to buy or renew domains. I have to use Firefox instead. Firefox is great -- I use it for many things -- but the bulk of my work is on I.E. right now.
Sincerely,
David Gillaspey
President
Great Church Websites
David Gillaspey
Sun., Mar. 27, 2005, 3:04 pm
Your includes can use a relative reference if the include files are in a directory off the root level (\includes\ for example).
I agree. However, if you download and install complete web "applications" such as phpBB (php- and mySQL-based forum software formerly used for this forum), vBulletin (php- and mySQL-based forum software currently used for this forum) or aMember (php- and mySQL-based membership/subscription software used on Great Church Websites), you will install a directory (for the web application) at the root level of your website that will contain 100s of files, including -- especially -- many template files in one or more subdirectories.
If you want to make the web application visually look like the rest of your website, you will be modifying a lot of those template files. (I did that for phpBB and aMember, but decided not to for vBulletin, the programming for which is really complex. And anyway, I want the forum to be perceived as having a life of its own and not be just a part of Great Church Websites.) The relative references to your include files that work for the rest of your site, won't for the files in the template subdirectories of the web application directory. That's why I figure it's better to start with absolute references to begin with.
Sincerely,
David Gillaspey
President
Great Church Websites
iamcam
Mon., Apr. 25, 2005, 1:38 am
Not completely on-topic, but I just wanted to pass-along a great website somebody on my team pointed me to: http://csszengarden.com. There are some really great CSS examples - really quite amazing what you can do with the technology.
David Gillaspey
Wed., Apr. 27, 2005, 3:08 pm
Not completely on-topic....Close enough, I'd say.
The point of the site is to provide web designers with standard text and some other elements, then invite or allow them to create a new or optional layout for the site using CSS alone (as opposed to altering the HTML code).
I like what it says about CSS: "The css Zen Garden is about functional, practical CSS and not the latest bleeding-edge tricks viewable by 2% of the browsing public."
Warning: artists can provide art of their own choosing. About this, the rules state: "Please keep objectionable material to a minimum; tasteful nudity is acceptable, outright pornography will be rejected."
In the upper right of the main site (the location changes with different designs, however) is a list of alternate designs that have been contributed to date (eight total, as of this writing). Clicking any one of them loads an alternate CSS style sheet, dramatically changing the layout. Much of the change can be attributed to a new set of graphics, however.
Definitely worth a look see. So far, no nudity, except for naked insects in the "bug" design. The cockroach is a little frightening.
Sincerely,
David Gillaspey
President
Great Church Websites
generalhavok
Tue., May. 3, 2005, 7:23 am
Using PHP requires your pages have the .php extension rather than the usual .htm or .html extension. PHP pages can contain and usually do contain a mix of HTML and PHP code, however. If fact, it doesn't hurt for a page comprised of nothing but HTML code to have an extension of .php. It is rendered by the PHP server as an HTML page just fine.For those using Linux servers, any file extension will do as long as you edit your .htaccess file. It should be in your root. Simple add something like this to it and php can be rendered on any page with the extensions you choose:
AddType application/x-httpd-php .php .php3 .html .htm .shtml
So: pages with the above extensions have all been given permission to render php. You can add any extensions you'd like including (as far as I know) cfm and aspx as well.
I use includes wherever I can. They're as important to me as external stylesheets, which are almost EVERYTHING to a designer who changes things regularly. My usual includes are 1)navigation, 2)copyright year, and 3)possibly some header info. I also like using includes for rotating images, quotes of the day, etc.
David Gillaspey
Tue., May. 3, 2005, 1:19 pm
For those using Linux servers, any file extension will do as long as you edit your .htaccess file.Hi General Havok,
Thanks for the additional info.
FYI to all, to clarify things, I think the assumption here is you still have to have the PHP server software installed, regardless.
Sincerely,
David Gillaspey
President
Great Church Websites
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.