homepage Welcome to WebmasterWorld Guest from 54.226.213.228
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

    
Do I need a CSS for this? or includes? or.?
Makaveli2007




msg:3711067
 11:22 am on Jul 30, 2008 (gmt 0)

Hello,

I'm a noob when it comes to creating websites. I created my first template and have an organized structure for the site, etc..

However what I realized is that if I want to change the path of one link in the navigation (or something else which I have on every page), I'll have to go to every single page (its html-file) and change the name of the path.

Is there a way around doing this? Using a CMS? I've also heard of 'includes' (I assume this is server side includes = SSI)?

I guess if it costs too much money, I'll have to do it manually for now and make sure my site doesn't get too large for now, because I'm not making any money off my sites and can't afford to spend a few hundred dollars on the right software for this (and have heard most free CMS caused a ton of problems).

Any ideas what I could do so I dont have to edit ? thank you!

 

Marshall




msg:3711093
 12:03 pm on Jul 30, 2008 (gmt 0)

You can convert your pages to .php, .asp or .shtml and use includes as you mentioned. You can also use a webbot include:

<!--webbot bot="Include" U-Include="navigation.htm" TAG="BODY" -->

but there are two things. The include page should ONLY contain the navigation because, as you can see, the webbot includes inserts all the information in the <body> tag and, this is a client side include, not a server side.

Marshall

Marcia




msg:3711100
 12:45 pm on Jul 30, 2008 (gmt 0)

<!--webbot bot="Include" U-Include="navigation.htm" TAG="BODY" -->

OMG, I can't believe my eyes. That's proprietary Front Page stuff!

<=== Aghast, runs away screaming in terror

You can use PHP includes on pages with an .html or .htm file extension, all you have to do is put an entry in .htaccess for Apache to parse the html files for PHP. I do it on every single site; all you have to do is update one text file and the entire site is updated, wherever you have the include coded.

Marshall




msg:3711109
 12:56 pm on Jul 30, 2008 (gmt 0)

It does work. Hey, and empty your SM box. I can't send you mail.

Marshall

encyclo




msg:3711122
 1:17 pm on Jul 30, 2008 (gmt 0)

<!--webbot bot="Include" U-Include="navigation.htm" TAG="BODY" -->

This won't work on any server I run. You have to have Front Page extensions enabled, and Front Page has been discontinued, so it is not a future-proof technology. Fewer and fewer hosts will support this syntax, especially those with non-Windows servers (the majority).

The standard mechanism (built into Apache and other web servers) is via a server-side include:

<!--#include virtual="navigation.htm" -->

Receptional Andy




msg:3711123
 1:19 pm on Jul 30, 2008 (gmt 0)

This won't work on any server I run. You have to have Front Page extensions enabled

Is that right? As I understood it (and I haven't seen a copy of FP for years) the software actually inserted all the included html prior to upload.

encyclo




msg:3711125
 1:21 pm on Jul 30, 2008 (gmt 0)

the software actually inserted all the included html prior to upload

In that case, you have to upload via FrontPage and not via a standard FTP/SSH client - and in that case, you still have to have the FrontPage extensions installed on the server... and only use Front Page for authoring (which is even worse!). :)

Marcia




msg:3711128
 1:25 pm on Jul 30, 2008 (gmt 0)

Yes Andy, and you have to upload ALL the pages of the site all over again every single time you update the danged FP includes.

Issue:

I understand that SSI and PHP don't play well together on the same site. If PHP includes are used, rather than SSI, there are all kinds of neat little PHP tricks and time-savers that can be used on the site as time goes on. That's 100% the reason I chose PHP includes and will continue to use them. PHP rocks!

Just MHO.

Added:

In that case, you have to upload via FrontPage and not via a standard FTP/SSH client - and in that case, you still have to have the FrontPage extensions installed on the server... and only use Front Page for authoring (which is even worse!).

Arghhhh! What a horrifying thought. Even M$ stopped releasing and supporting FP.

[edited by: Marcia at 1:28 pm (utc) on July 30, 2008]

The Contractor




msg:3711168
 2:04 pm on Jul 30, 2008 (gmt 0)

You can parse .html and .htm extensions as SSI. Look in your hosting control panel under apache handlers in cPanel if that is what you are using or turn on SSI in HSphere and then add the extensions or you can use .htaccess to parse them [webmasterworld.com...] .

You then cut out the html code you want as an "include" into a separate page and name it topnav.html for example. You then place in the "exact" area you cut the code out of your page <!--#include virtual="/topnav.html" --> and upload it to the root of your domain (yoursite.com or public_html).

In the future you will only need to update the "topnav.html" file and upload it...

Marcia




msg:3711177
 2:18 pm on Jul 30, 2008 (gmt 0)

How to Parse HTML files for PHP [google.com]

Put the entry into .htaccess to do it, and then make a folder for the site called /includes/ so you remember where they all are.

You put elements like navigation into plain text files (like in Notepad) and save them with filenames like topNavigation.php or footer.php

Then, where you want it to appear, you put the following code using the proper filepath to your /includes/ folder:

<?php include('includes/footer.php'); ?>

Basically, you're doing it the same way you code graphics onto pages that are in the /images/ folder. Once you get this working the first time and get a glimpse of the beauty of it, there's no turning back. You will love it!

Makaveli2007




msg:3711211
 2:51 pm on Jul 30, 2008 (gmt 0)

Hehe,

thanks for the replies, but I must admit I'm a bit confused now.

It sounds like "includes" isn't any software or something, but simply the process/technique of creating a new file for example navigation.html and then writing a line of code in the .htaccess file so that the host understands that the file navigation.html has to be used for certain .html pages?

Couldn't you simply use a line of code in every html-file for which you need the navigation.html - file ...the same way you do it with CSS? Ok actually this wouldnt be more simple, but why do you reference a CSS.file in each html file, but only reference the include-file in the .htaccess-file, once?

Does it matter whether I use .html files or .php files? If I dont have a dynamical site right now, could I simply go with .html files (for the include-file) and change it later on? I assume later on it would be just as simple as right now?

Sorry, but Im a bit confused! lol guess Ill have to read a tutorial on this stuff

The Contractor




msg:3711245
 3:20 pm on Jul 30, 2008 (gmt 0)

Nope, the .htaccess method or .httpconf method (through hosting conrol panel) simply tells apache that .htm or .html files can parse SSI (server side includes)instead of the normal .shtml extension associated with SSI.
You do NOT add a line in .htaccess for each include file...

You are correct, no cost or software involved, simply a setting in apache handlers.

Most sites I put together have at least 3-4 includes for things like headers, footers, navigation, and other items that make it very easy to change sitewide in the future by editing one file instead of 100's or 1000's of pages.

[edited by: The_Contractor at 3:22 pm (utc) on July 30, 2008]

The Contractor




msg:3711259
 3:35 pm on Jul 30, 2008 (gmt 0)

The reason I prefer parsing .htm/.html extensions as SSI instead of PHP is SSI always takes into account the includes start in the root. Meaning using SSI <!--#include virtual="/topnav.html" --> will be called no matter what level your page is at so if it is at "yoursite.com/thisfolder/thatfolder/mypage.html" it will still call the include correctly. Of course you can keep all includes in one folder like <!--#include virtual="/includes/topnav.html" --> and it will still call them correctly no matter where your page is located that is calling the include file.

If you parse .htm/.html as PHP, it would look for the include file <?php include('footer.php'); ?> in the current directory structure the current page calling the include is in (yoursite.com/thisfolder/thatfolder/) ....unless I am completely wrong.

Receptional Andy




msg:3711265
 3:40 pm on Jul 30, 2008 (gmt 0)

To reference root you can use the $_SERVER['DOCUMENT_ROOT'] variable:

<?php include $_SERVER['DOCUMENT_ROOT'].'/footer.php'; ?>

The Contractor




msg:3712033
 1:43 pm on Jul 31, 2008 (gmt 0)

Thanks for the tip !

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / New To Web Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved