/    Sign up×
Community /Pin to ProfileBookmark

Creating A Template And Then Implementing Each Element

I’m wondering if it is possible to do the following:

template.htm

[code=html]<html>
<head>
</head>
<body>
<div id=”mainDiv”>
</div>
</body>
</html>[/code]

index.htm

[code=html]<html template=”template.htm”>

@implement “mainDiv”
{
<p>This is the home page!</p>
}

</html>[/code]

someOtherPage.htm

[code=html]<html template=”template.htm”>

@implement “mainDiv”
{
<p>This is some other page!</p>
}

</html>[/code]

Basically, I would create a template that has all my styling etc… in it. Then in new pages that have the same styling and setup, I could just change the content of a specific tag to match the file’s appropriate content.

to post a comment
HTML

5 Comments(s)

Copy linkTweet thisAlerts:
@Ryan_BMay 26.2011 — If you mean have a lot of things with the same colors/sections/styles, then you might want to look into a little bit of CSS. It lets you add the same style to different html pages from the same CSS file. Here's a linky: http://www.tizag.com/cssT/
Copy linkTweet thisAlerts:
@grimesdMay 26.2011 — If you an external CSS Stylesheet, you have the same layout (As Ryan B mentioned) across all your pages. Once you create the template of how you want your site laid out (Without any actual content in it and as long as your template contains the link to your external CSS file), open up template.htm every time you want to create a new page and save it as another..

For example..

Open template.htm > save as index.htm

Open template.htm > save as contact.htm

I also suggest using .html in place of htm.
Copy linkTweet thisAlerts:
@RParkesauthorMay 26.2011 — If you mean have a lot of things with the same colors/sections/styles, then you might want to look into a little bit of CSS. It lets you add the same style to different html pages from the same CSS file. Here's a linky: http://www.tizag.com/cssT/
[/QUOTE]


No, it's not the styles that I'm concerned with, it's the content. I want to be able to "implement" an element as needed and change the content.

If you an external CSS Stylesheet, you have the same layout (As Ryan B mentioned) across all your pages. Once you create the template of how you want your site laid out (Without any actual content in it and as long as your template contains the link to your external CSS file), open up template.htm every time you want to create a new page and save it as another..

For example..

Open template.htm > save as index.htm

Open template.htm > save as contact.htm[/QUOTE]


I know I can do what you are suggesting, but I'm coming from the change management angle. Yeah I can create a skeleton and then "Save As" for each additional file but what if I want to change the layout afterwards? I would have to go into each file and change it. Or, change the skeleton then paste in all my new content and "Save As" etc... This is what I want to avoid. If I could some how "inherit" a document (skeleton) and then "override" elements I would be able to do this... just don't know if it's possible.

I also suggest using .html in place of htm.[/QUOTE]

Why's that...?
Copy linkTweet thisAlerts:
@grimesdMay 26.2011 — I believe .html extensions are more recognizable by google search engine. Just a personal opinion on that one.
Copy linkTweet thisAlerts:
@criterion9May 27.2011 — I believe .html extensions are more recognizable by google search engine. Just a personal opinion on that one.[/QUOTE]

Categorically untrue.


@OP, Have you looked into using PHP or other server-side language? It sounds like you are trying to create one page and the insert the appropriate contents in places.

[code=php]
<?php
//the contents of these variable could be loaded from anywhere (database, filesystem, etc)
$content = "This is some dynamic content";
$andSomeDynamic = "and some dynamic contents too";
?>
<html>
<body>
<h1>Some static stuff here</h1>
<div id="content"><?php echo $content; ?></div>
<div id="footer">Some static stuff <?php echo $andSomeDynamic;?></div>
</body>
</html>
[/code]
×

Success!

Help @RParkes 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.5,
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,
)...