Buttons and page redirection
I've taught myself some web dev and thought of a question re buttons.
When I'm doing my buttons, i'm linking to another html page. So this means for every page I have a separate html page (Which I'd expect) but it means on every page I have to write all the html for things that are identical on every page, such as background, buttons, layout formatting etc etc.
Is this the norm or is there a better way, like is it possible to make templates where you only have to replace the things you actually want to change but don't have to rewrite (well ok, copy and paste) all the html code every time i want a new page.
It would seem to me and my limited knowledge that I will have to keep all the code in every page (unless I use JS or frames but i dont really want to) but I was thinking, if a company has a massive website surely they dont have loads of html files that all contain code for the borders/buttons etc etc or do they?
Easiest way to do it would be to piece your pages together from a webserver.
Do you know any server side languages, such as PHP?
I dont actually, but I'm a programmer (not done web before though) so I'm sure i could learn without too much trouble. how would it work in php then? I'm obviously not looking for a php lesson, or any code, but just an explanation of how you use it to build ur pages.
Originally Posted by thraddash
How are websites usually put together; with server-side code?
I can't think of a better way than to use a server language.
As a basic template example:
<div style="border: solid 1px black;">HEADER</div>
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
Then just add them to a page (this is the really simple version btw)...
<div style="border: solid 1px black;">FOOTER</div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php require(header.php); ?>
<?php require(navigation.php); ?>
PAGE SPECIFIC CONTENT
<?php require(footer.php); ?>
Ah very good. I'd tried doing something similar with html files actually. Worked but couldnt quite get formatting right.
What's the differences in the many server-side languages then; why use php over, say, asp?
I appreciate your help!
There is actually a website called that describing what you've just asked :P
You can't be good at everything, I just so happened to learn PHP and it has done all that I could ask for.
Good luck making your choice.
ah cheers for that. So PHP is more flexible with databases and server compatibility, is like C++ (which I have coded in), is faster and allows me to use free tools and servers?
Sounds like a no brainer to me. Thanks for all your advice!
I am new at this malarky too and have been experimenting with server side html includes. (No need for php or asp etc.)
You simply create one file with the content to be duplicated elsewhere and call it what you like.
Then in your html doc you put the following in where you would like the included segment to be inserted:-
<!--#include file="filename.html" -->
You save this file as whatever.html or .shtml (apparently the latter is preferred by some servers, although I don't know why).
The resulting page in the browser looks like a fully formed page.
You can have many includes in one document and, if you wanted to, you could make a template containing all of the includes for future use.
I heard, somehwere along on the line, that using includes speeds up page loading, as the included data is cached.
Cheers for that tip. Tried that myself but the formatting never came out 100% perfect. Done it the PHP way n it's all dandy
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread