PDA

View Full Version : SSI Server Side Includes Tutorial. Pt 5: Yay it is all over.


entimp
10-31-2003, 12:30 AM
Intro (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-25590.html) - Pt 2 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-2-the-ssi-25616.html) - Pt3 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-3-the-code-for-our-example-25644.html) - Pt4 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-4-save-the-code-30534.html) - Pt5

Okie dokey... so we now have the includes we need. These are:
meta_and_header.asp
nav.asp
before_content.asp
after_content.asp
end_page.asp

You saved these to a folder called 'includes didn't you? No? Then go do it now!

Back? Good! Then let's make our fist web page that uses
SSI's. This will be an index page for the very simple
website we are creating.
Open your design tool of choice... notepad or dreamweaver
for example. Save this file as index.asp, remember the asp
extension or the server will not read it before it gets sent.

Now you have a blank doc, we need to add some includes. The
first one will be 'meta_and_header.asp, and then add the
rest. It will look like this:
<!--#include file = "includes/meta_and_header.asp" -->
<!--#include file = "includes/nav.asp" -->
<!--#include file = "includes/before_content.asp" -->
<!--#include file = "includes/after_content.asp" -->
<!--#include file = "includes/end_page.asp" -->

All things being equal, that I lead you down this strange
path correctly and you did as I said... the instructions
above saved as index.asp will render you a perfectly valid
web page. Without the content or footer areas being empty
that is.

That isn't good is it? Well it is to an extent. I now want
you save this file as my_template.asp so that when you add
content all you need do is refer to this file.


So back to index.asp, open it and some content of your
choice.
<!--#include file = "includes/meta_and_header.asp" -->
<!--#include file = "includes/nav.asp" -->
<!--#include file = "includes/before_content.asp" -->

Shock Horror the content goes here! You would have never
worked that out would you! You can add what ever you want,
plain text, or normal markup (html), even scripts.


<!--#include file = "includes/after_content.asp" -->

You can do the same here for the footer region...
alternativly you can create custom content, save it as an
ASP file and serve it as another include. This seems to be
awful lot of work for a simple page doesn't it... well hang
in there.

<!--#include file = "includes/end_page.asp" -->

Now create the files:
biologists.asp
links.asp
article.asp
gallery.asp

Add the content to the template you made and save it as one of the above. Remember your content can be saved as another include, and not just written into a template page. Remember when writing your links you are directing the anchor at one of the files above and not the individual include files. I hope that makes sense.

Now send all your files to your ASP enabled server, remember you cannot run these to test from your home computer. Once uploaded you should be able to test them.

I hope that gets you off and running and that if I have missed something crazy out you will roast me for it... politely of course.

It has been a while since I got round to wrapping this all up. It wasn't for Peg nagging me (in a polite and constructive way ;) ) like my mum would have I wouldn't have got my lazy finger out and got this out of the way.

So a big thank you Pegasus.

I will of course edit this as I go along to clear up any confusion I have may have put in your direction. This can only be done if you reply and point it out to me in the relavent thread.

So there ya go! Hope this kinda helps and puts a few of you on the path of more confusing and screwed up web design.


Intro (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-25590.html) - Pt 2 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-2-the-ssi-25616.html) - Pt3 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-3-the-code-for-our-example-25644.html) - Pt4 (http://www.htmlforums.com/all-around-tutorials/t-ssi-server-side-includes-tutorial-pt-4-save-the-code-30534.html) - Pt5

Pegasus
10-31-2003, 01:14 AM
You're quite welcome, Entimp. *lol* Although, I don't think it was the nagging so much as the constant "dumb questions" coming from me that prompted you to finish. Self-preservation and all that.

Okay... that could be where I went wrong.

I don't have a folder called "includes". Of course, none of my links refer back to an include folder, either, and they seem to work.

What I have for a hierarchy is:

Main Site Folder
hindex.asp (the header file for the index page)
index.asp
commnav.asp (a nav file that's common to most of the sections, but not all)
Section Folder
>>csection.asp (content for section's main page)
>>hsection.asp (header for the section, including all the meta tags, etc.)
>>nsection.asp (navigation for the section, if necessary)
>>section.asp (the intro page for the section)

Each section has this set up, as well as the individual contents of each new 'page'. And that's where I'm having problems.

Having what amounts to 2 pages for content - the content itself and the combined page, gets a bit awkward. What I tried to do was have the page links for the section come up in an iframe in the 'csection' page. <sigh> But that only works sometimes, and not if I specify the source of the iframe as a page. The content comes up in a separate window.

Except in one case where I put the content into a table that fits into the iframe. That works. I should maybe add a table to the other content pages?

If nothing else, Entimp, you've taught me a new way of looking at web pages. Having to break things down for an asp file makes me think more about how to arrange the site, what's vital and what isn't.

<groan> And once I get this headache with the iframe pages sorted out, it'll be a whole lot easier to add pages to my site. I'll only have to update 2 pages - the navpage for that section and the 'Updates' section on the main page - rather than 3 or 4 pages, plus creating an entire new page for whatever I'm adding.

Thank you ever so much!

Peg

entimp
10-31-2003, 01:28 AM
No problem at all glad it helped.

By having a folder called includes you efectivly have another level order amongst the chaos. You will know where the files are it is easier to mentally design the web page with such order before putting the files into practice.

One way I find that makes it easier to decide what is an include and what is not is to write a generic page in html as I did in the tutorial. A page that would fit every page in your site.

I then extract all the generic components that would become includes and save them as such. It is then just a case of naming them with a convention you are happy with, creating a template file with the includes and then creating pages as and when you need them by filling in the blanks as it were.

Table structures are good for this as you can control the size and layout of the page and they have very clear points to start and terminate given includes. That was why I used it in the tutorial but alas didn't make a point of this.

Pegasus
10-31-2003, 01:52 AM
<sigh> That's my problem. There is no 'generic' page for the entire site.

Each section has a generic page, yes, with different meta, title and header image information for each section, but only the layout and colour scheme is the same for all the pages.

The only problem with having an includes folder is that most of the pages would be 'includes', and divided into sections.

Or, as you have in your example, I could make an includes folder for the header and nav files and add them to the content pages. Work back from the content, as it were, rather than down from the section. Hmmm... I'll have to think about that.

*lol* I do love to complicate my life, don't I?

Peg

giz
11-01-2003, 03:55 PM
Since the <title> and meta description are unique to each page, I do not put that information in the include file. I put it in the main file where the page content also resides (i.e. in the page that has the include directives within it, those then calling the other files in).

Jason20
12-10-2003, 12:46 AM
Hey great tutorial. Worked great for me. Gonna save LOADS of time.:newbie:

entimp
12-10-2003, 12:59 AM
Glad it makes sense and works for you. Any improvements or questions then fire away.

sh00ter555
02-21-2004, 05:31 PM
Ok, i think i was lost completely on this part.(part5).

So let me tell you what i think i understand, and then maybe u can just fill in the parts i didnt understand.

So i have all these files saved in a folder called 'includes'
meta_and_header.asp
nav.asp
before_content.asp
after_content.asp
end_page.asp


ok, so now i understand i need to save this file below as index.asp:
<!--#include file = "includes/meta_and_header.asp" -->
<!--#include file = "includes/nav.asp" -->
<!--#include file = "includes/before_content.asp" -->
<!--#include file = "includes/after_content.asp" -->
<!--#include file = "includes/end_page.asp" -->


ok, if thats right then i understand i save this file again as 'my_template.asp' correct?

ok if that is alright then im confused here:

Now create the files:
biologists.asp
links.asp
article.asp
gallery.asp

what exactly am i sopposed to make these files for? are these files above what i want to be displayed? Can i change them if this is what they are for?

Pretty much after that im lost.

can u please fill in the steps i missed or missunderstood?

Thanks again, and i think u did an excellent job on ur tutorial, and i appricate all the work you went thruogh to accomplish it. I think it may just be a little to advanced for me, but with your help i think i can figure this out.

Jason

entimp
02-23-2004, 09:19 AM
I missed these... I'll come back at ya tonight on them. Busy on my site then sleep :P

entimp
02-24-2004, 12:39 AM
Ok you save a template so that you don't lose this file. It makes it easier when you come back and add more content. You simply open this file and edit it.

The reason you create the other files: When you click a link to another part of your site... it needs to be a page built up with the includes, the only thing that changes is the main content.

IE the link 'biologists' will lead to a page called biologists.asp which is built up of the includes.

You have to understand this is saving you time in the long term. So when you change the layout in the nav include the biologists.asp page is automatically updated.

Does that help?

And of course you can change the names... the above tutorial used an example called 'biologists for newbies' I think, and thus the file examples were tailored for that.

sh00ter555
02-24-2004, 07:02 PM
Yes, that helps, if i have any other questions ill post them on here.

PS: i was talkin to one of my friends and he said you can do this by using normal html. He said this code work work just as well:


<html>
<head><title>Jason's Table</title></head>
<body>
<center>
<table width="750" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</table>
</center>
</body>
</html>

What do you think of this code? Will that work just as well?

pyrexyn
02-24-2004, 07:10 PM
Thankyou very much entimp. I used to stay away from ASP because it seemed like a language as complex as Java or something. So let me get this clear: ASP is simply a way of putting data together and whatnot? If I know PHP (which has includes and stuff), ASP shouldn't be a problem? And saving a file as *.asp does not do anything at all except render it as a type that can be accessed by the asp server? (Not exactly sure what if my question is even valid, because I don't know asp)

entimp
02-24-2004, 08:25 PM
Shooter that layout is fine.

Remember you are breaking up the table in different includes for one reason.

Say you have 30 documents using the same header and footer. You may want to change the content of the the header/footer. Now instead of doing each file individually... you only have to change it once in the includes.