Forum Moderators: open
Having to make the same changes across all of the pages is already getting a little tiresome (and error-prone) and will only get more so.
What I would like to do is this. When I create a new page, I would like to just type up the new content and then start a process that generates the final page, including the mast and side menu (maybe even cuts out unnecessary whitespace to reduce filesize). It would also, of course, regenerate all of the other pages so that the new menu items appears in all of them. Similarly, if I want to make a change to the masthead (which will not happen very often at this stage, but may happen) then I would like to just change a template and hit the button. Once the page generation is complete, and all the pages have been checked out in various flavours of browsers, then I can dump it all onto the server.
Does anyone know of any software that can do this kind of thing? Simple file inclusion would be easy - the main feature I'm after is the ability to modify the markup based on the page being generated (i.e. adding class="selected" to the tag for the menu entry of the current page).
Either Windows or Linux based software would be fine. btw, I'm not using any fancy html editors to write up the pages - just vim. If any html editors do this kind of thing, I'd consider using one of them (I'd really prefer to stick with vim, though - I'm just so familiar with it).
Many thanks for your help.
First, let me tell you this - there are several programs that say they do this, which usually results in code crappier than if my Grandmother made it :)
On a more serious note, the closest you'll come is probably a program that lets you use a template for any new documents you create. I know Macromedia HomeSite (previously owned by Allaire) does this. And, personally, I'd prefer that over a program that applies a template afterwards.
Finally, Welcome [webmasterworld.com] to Webmaster World!
For example, you might create a php file that looks like this...
[pre][1]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title><? echo $title;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" type="text/css" media="all" href="/styles/default.css">
</head>
<body>
<div id="headingbar">
<h1><? echo $sectiontitle;?></h1>
</div>
<div id="content">
<h2 id="pagetitle"><? echo $pagetitle;?></h2>
[/1][/pre]
and call it header.php and then do likewise for the common footer code.
Then you don't need to re-type this code for every new page you create, instead you just do this..
[pre]
$title = 'Your Site';
$sectiontitle = 'Welcome';
$pagetitle = 'A generated page';
<?php include_once 'header.php';?>
<p>My content goes here</p>
<?php include_once 'footer.php';?>
[/pre]
..which is great because if you decide you want to change the header or footer html you only need to do it in one place and the whole site changes.
Does HomePage allow you to create your own templates? And if you change the template, will that affect all that documents that use it? Also, would it be able to do the sidemenu thing I described? Thanks.
grahamstewart,
I currently know practically nothing about php (except for its existance and what I've just seen in your post) but I will look into it. Thanks for your help.
You can also create templates with FP although I don't know how. Maybe it can work for you by combining include pages and templates.
It will save you hours and you can do your sidemenu thing.
Library items and templates are linked assets: editing a library item or template updates all documents in which these assets have been applied.
Use library items and templates when you want to reuse specific content or design elements throughout a site or across multiple sites. Library items are intended for individual design elements, such as a site’s copyright information or a logo. Templates let you control a larger design area. A template author designs a page and defines which areas of the page can accept either design or content edits.
I used to do it in homesite, not with templates, but liberal use of the global replace function.
The other way, like someone else mentioned ,is to use SSI which is easy to get your head around but laborious to apply to hundreds or thousands of pages.
An alternative is to generate your own template and have a CMS creating the content. This could be done in anything from PHP to ASP.
Something I have done in the past when I insisited on haveing the menu in an include is to call a javasvript function to detect the title of the page. I would then use a bunch of if/else statements and if I matched the title of the page I would set the background color of the navigation to the highlight color.
I'll try to post some code.
Here is what a template would look like.
<html>
<head>
<title>My Site - Products</title>
<meta name="description" content="blah blah blah">
<meta name="keywords" content="blah, blah, blah">
<!--#include file="header.html" -->Content Here
<!--#include file="footer.html" -->
</body>
</html>
And here is what the html inside the includes would look like rendered in the browser. You can alos link to external js and css files.
<head>
<title>My Site - Products</title>
<style type="text/css">
<!--.Navlink1,.Navlink2,.Navlink3 {COLOR: #ffffff; TEXT-DECORATION: none; font-family: arial; font-size: 10pt; font-weight: bold;}
a:link.Navlink {color : #ffffff;}
a:visited.Navlink {color : #ffffff;}
a:active.Navlink {text-decoration: none;}
a:hover.Navlink {text-decoration: none;}-->
</style>
<script language = "javascript">
<!--function LmOver(elem, clr)
{
//alert(elem);
elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#ffffff";
elem.style.cursor = 'hand'}
function LmOut(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#FFFFFF";}function LmDown(elem, clr)
{elem.style.backgroundColor = clr;
elem.children.tags('A')[0].style.color = "#FFFFFF";}function LmUp(path)
{location.href = path;}function setcolor(){
strPage = document.title;
if (strPage.indexOf('home')>0){
document.all.nav1.style.backgroundColor = "#ff0000";
}
else if(strPage.indexOf('index')>0){
document.all.nav2.style.backgroundColor = "#ff0000";
}
else if(strPage.indexOf('Products')>0){
document.all.nav3.style.backgroundColor = "#ff0000";
}}
//-->
</script>
</head>
<body onLoad="setcolor()">
<table border="0" cellspacing="1" cellpadding="1">
<tr><td id="nav1" onMouseover="LmOver(this, '#003366')" onMouseout="LmOut(this, '#336699')" onMouseDown="LmDown(this, '#003366')"
onMouseUp="LmUp('index.html')" bgcolor="#336699"><A HREF="index.html" Class="navlink1"> Home</a></td>
<td id="nav2" onMouseover="LmOver(this, '#003366')" onMouseout="LmOut(this, '#336699')" onMouseDown="LmDown(this, '#003366')"
onMouseUp="LmUp('contact.html')" bgcolor="#336699"><A HREF="contact.html" Class="navlink2"> Contact</a></td>
<td id="nav3" onMouseover="LmOver(this, '#003366')" onMouseout="LmOut(this, '#336699')" onMouseDown="LmDown(this, '#003366')"
onMouseUp="LmUp('products.html')" bgcolor="#336699"><A HREF="products.html" Class="navlink2"> Products</a></td></tr>
</table></body>
I agree with the posts about SSI. Server Side Includes are wonderful when you want to include the same content on every page.
Thus, if you change the included document (or in this case only part of one) all pages will be instantly changed! The only bad part about this is that you can't really "preview" this behavior on your computer.
It's kind of cluncky but it does work. The benefit is that the FP extensions save the pages as full html docs so there's no other server overhead involved.
Joel_Taylor, if the site is going to be fairly large you should look into Dreamweaver. Besides supporting templates it supports sub-templates so different sections can have their own characteristics. I played around with a trial copy when it was released but decided that the learning curve and converting sites was just too much at the time.
<added>Drawback to Frontpage is that you must rely on your server people keeping the Frontpage extensions in good working order. If not you can have major headaches such as a site being unusable for a month or so.</added>
Jim
Two others I know of is DBtoWEB (I use this) and WebMerge (have not used extensively). But these are more complicated and require a database to work off of. It may be more than you need.
That's for sure!
If you're gonna do it, do it properly. [smarty.php.net]
You'll need to invest some time and effort initially but you'll never look back..
And welcome to WebmasterWorld ;)
Nick
The problem may be highlighting the class="selected" for the navigation. Depending on what your doing with the CSS you may have to end up with placing the menu on each page instead of an include.
One way to handle this in a static manner is to set a different id for the body of each page. Then you can use this id to style the links. e.g. html like this..
<body id="homepage">
<div id="menu">
<a href="/index.html" id="linkhome">Home</a>
<a href="/pics.html" id="linkpics">Pics</a>
<a href="/sounds.html" id="linksounds">Sounds</a>
</div>
</body>
and CSS like this...
#menu a {
color: #0000ff;
background: transparent;
font-weight: bold;
}#homepage #linkhome, #picspage #linkpics, #soundpage #linksounds {
color: #0000aa;
background: transparent;
font-weight: normal;
}
So normal menu links are bold and bright red, but the current link is duller red and normal. (Not very nice styling but you get the idea :))
Just to clarify, include pages don't use FP server extensions.
MrSpeed: I really hope thats not the header that you are using. Try adding a doctype and moving your css and javascript to external files. That should speed up the page loading. Then try validating your html.
I just copied some proof of concept code I was working on for somebody and would do all those nice things before going to production.
grahamstewart - I'll have to try that code of yours.
Just to clarify, include pages don't use FP server extensions.
gph,
They sure do, or at least they are affected by them if they go bad. Had a huge problem last year with three sites almost unusable for the better part of a month. My very big, very muckety-muck host (no longer) refused to install the needed SP1 patches after upgrading to XP versions.
See MS KB Q298827 for NT [support.microsoft.com] or MS KB Q299360 for Unix [support.microsoft.com]
The extensions rewrite and update pages affected by changes to any included pages ("Processing web updates" message after publishing).
Jim
I've used them on more than 1 server that didn't support FP extensions. Specifically default space that came with cable service. They didn't support anything but a few premade CGI forms let alone FP extensions.
I can see where using extensions could cause problems but I'm 100% sure that include pages don't require them. It looks to me like staying away from FP extension enabled servers would be the answer.
I thought I qualified what I said:
They sure do, or at least they are affected by them if they go bad.
And you're quite right. From what I understand if your use FP on a server that doesn't support extensions you're basically FTPing the locally saved files up to the server, which then do have all the updated include pages in place.
When publishing to an extension-enabled server, say after you made a change to one include page, the publishing routine only sends the changed include page, all the other pages are updated on the server.
As for staying away from extension-enabled servers, why not, if you aren't using any of the features that do require them.
Jim
Here is something you can try to prove it to yourself.
1) Create a test site/web offline and use the inlcude function. Now close FP and open up the file in any text editor and view the code, you will see that the content of the include page is already within that file (darn FP uses it comments everytime though.)
Does anyone knows how to not have those comments?
NeedScripts
You're absolutely right. As gph states above FP extensions are *not required* for include pages to work.
But, as I state above, if FP extensions are installed then the behaviour is different and funky extensions can impact the site, as noted in the two MS knowledge base articles I cited.
As for those comments <!--webbot bot="Include"...,etc> that's the way FP calls and checks the includes. As far as I know there's no way around this.
Jim