/    Sign up×
Community /Pin to ProfileBookmark

Buttons and page redirection

Hi
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?

Cheers ?

to post a comment
HTML

8 Comments(s)

Copy linkTweet thisAlerts:
@thraddashJan 27.2011 — 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?
Copy linkTweet thisAlerts:
@ministe2003authorJan 27.2011 — 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?[/QUOTE]


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.

How are websites usually put together; with server-side code?
Copy linkTweet thisAlerts:
@thraddashJan 27.2011 — I can't think of a better way than to use a server language.

As a basic template example:

[B]header.php[/B]
[code=html]<div style="border: solid 1px black;">HEADER</div>[/code]

[B]navigation.php[/B]
[code=html]<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>[/code]


[B]footer.php[/B]
[code=html]<div style="border: solid 1px black;">FOOTER</div>[/code]

Then just add them to a page (this is the really simple version btw)...

[B]home.php[/B]
[code=html]<!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">
<head>
<title>Home</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

<?php require(header.php); ?>
<?php require(navigation.php); ?>

PAGE SPECIFIC CONTENT

<?php require(footer.php); ?>

</body>
</html>[/code]
Copy linkTweet thisAlerts:
@ministe2003authorJan 27.2011 — 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!
Copy linkTweet thisAlerts:
@thraddashJan 27.2011 — There is actually a website called that describing what you've just asked ?

http://www.aspvsphp.com/

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.
Copy linkTweet thisAlerts:
@ministe2003authorJan 27.2011 — 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!
Copy linkTweet thisAlerts:
@Spike201000Jan 31.2011 — 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.
Copy linkTweet thisAlerts:
@ministe2003authorFeb 01.2011 — 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 ?
×

Success!

Help @ministe2003 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...