|
Okay, so I've seen so many requests on this that I thought I'd write a quick
tutorial. It's basically the same as the one from codegrrl, but maybe this one
will be simpler to understand.
First, code your layout anyway you want, on frontpage or dreamweaver, or
anywhere you want it to make it, doesn't really matter. Make it a layout, don't
add any content to where to content will appear (the news page, the biography,
the filmography, etc)
*Note: I've put the files as .txt so when you access it, you will be able to
view the source as I'm not able to post the code here
Now, I think most people have trouble diving the layout, here is what I do when
I'm lost in my tables, if I'm happy with what I've got, in Frontpage I type the
word content in the place where I want my content to go, so, when I look in the
html I will know exactly where to slice, here for example a layout in html:
http://www.cauldron-cakes.net/php/index.html
Take a look at the html, see 'all the content appears here' ?
Everything that is above it, will go into 'header.inc' (you can rename it
anything you want, header.php, top.php, .txt, I like .inc because it means 'inclusion',
you can use whatever you want)
so, everything above the words 'all the content appears here' will be put into
header, view my header here:
http://www.cauldron-cakes.net/php/header.txt
see how the last line is a not closed table tag? I will get to it in a few
For footer.inc I will put everything that appears below 'all the content
appears here'
http://www.cauldron-cakes.net/php/footer.txt
So, continuing, on my index.php page all I will type is:
http://www.cauldron-cakes.net/php/index.txt
View page here:
http://www.cauldron-cakes.net/php/index.php
So, all your subpages will only need to have the include codes and the actual
content, nothing from the layout, so, next time you want to change your layout,
you will only need to change header.inc and footer.inc, or, I'm sure some of you
had this happened, after finishing a layout, you realise you forgot something,
and, if you have to change 30, 40 files, it's not fun, at all!
So, another example, a bio.php page would be:
http://www.cauldron-cakes.net/php/bio.php
And the source:
http://www.cauldron-cakes.net/php/bio.txt
I hope this makes sense to you guys.
So, what else can you do with php and inclusion? many things! You can, for
example, divide your layout into even smaller pieces (if you have a really long
html code, it could be wise), like, putting a header, a side bar and a footer,
but I wouldn't recommend unless you got the hang of header and footer first, one
step at a time, agree?
|
this is a pretty sidebar, the one that will repeat in every
page
|