# Question for hand-coders



## uoba (Oct 17, 2003)

Since I've delved into XHTML and CSS, my reliance upon DWMX has decreased (mainly because I use straight MX, and for most of the CSS I do, it cannot render correctly (and MX2004 is too slow)).

I'm happy to be able to free myself, and also to use it when necessary. However, one interesting thought came to my mind...

How do hand-coders deal with templates? Templates obviously save a lot of time. I change one part of the code in a template, the changes occur in the linked files.

How do you handle this with hand coding? Am I being naïve?


----------



## Arden (Oct 17, 2003)

I use my free PHP-enabled web host of choice, Host Ultra, and simply upload the files every time I change something.  However, I'm not sure what kind of template you're using, so this may be different for you... what kind of file are you using for your template?


----------



## uoba (Oct 17, 2003)

Well, since I don't know any other way at present, all templates are done in DWMX. Hence, they would be .dwt files (normally a master html file located in a template folder in the root directory)

What I need to understand is, whether the way DW does templates, is the same way in standard (X)HTML.


----------



## toast (Oct 17, 2003)

I personally use Find & Replace in BBEdit, which has a multifile find/replace capability.

Eg: I want to change my copyright date in my whole website.

I open BBEdit, Find and Replace.
Find: (c)2002 Replace (c)2003
Multifile search checkbox: checked.
Multifile criterion: Website (which automatically searches a whole folder, incl. nested ones if precised).

You can have multiple websites. Read more: http://www.barebones.com/products/bbedit/features.shtml


----------



## Pengu (Oct 17, 2003)

For things like nav bars, footer text, etc that is on every page, you could either
a) use a bit of php to: include the footer, header, whatever in each page, or make a master page (index.php) and use ?page=whatever links to tell it which page to include in the content area
b) use some javascript to do either of the above


----------



## uoba (Oct 18, 2003)

Thnx guys.

Pengu, your PHP suggestion was like a slap in the face to wake me up! Of course! I should realised!

The great thing about using the PHP include as well is that you don't have to rely on unneeded code as in dw templates (i.e. the referenced code/page doesn't need all the html. head etc. tags). 

Nice.


----------



## Sogni (Oct 18, 2003)

I don't like using ?page= for includes,
I use the Require Include code in PHP.

I basically design the layout as a straight-up PHP page, keeping in mind how I want to break it up (nav bar, header, footer, content, etc.).

I then create new files and copy 'n paste the sections I want into each file and name them appropriately (usually something like nav.inc.php).

Then the main index file and all the files that don't have the inc in the filename simply have nothing but a bunch of the require include codes calling each file.

I love PHP! I just wish I knew more than I do about it.


----------



## mr. k (Oct 18, 2003)

If you use bbedit there is a pretty good templating system built in.  You can just use #bbinclude <file> or something, and bbedit includes the file.  It's neat, but then <?php include="<file>"?> works just fine too.
And toast - in BBEdit 7 you can use #yearnum# instead of writing the year, And it will change automatically (I think you just need to open up the file on new years - it can't be completely automatic...)


----------



## uoba (Oct 18, 2003)

I suppose using the #bbinclude becomes another proprietary bit of code again though? Just as DW.


----------



## mr. k (Oct 18, 2003)

Yeah, but the only non proprietary solution is copy and paste, am I wrong?  Using php seems to be the least most versatile, but which ever method you chose you end up with mostly the same result.


----------



## uoba (Oct 18, 2003)

As long as I can get my head around the php way, I will hopefully stick with it (since our main developer likes to do it this way also, so it'll keep me up to speed with him!)

I dunno, I sort of see the php route as perhaps being more versatile, just a little bit trickier.


----------



## Pengu (Oct 18, 2003)

If you need any helo uoba, feel free to PM or email me.


----------



## uoba (Oct 19, 2003)

Thnx Pengu, I may take you up on that during the dark hours of a lonely night developing away!


----------



## Arden (Oct 19, 2003)

I, too, prefer to use the PHP method, though I prefer to have everything in one file called "template.php" as it makes it easier to maintain.

This is from a file I use called "HTML PHP Page Template":

```
<?
require( "./extras/template.php" );
$title="";
begin( $title );
?>




<!-- Replace this comment with content. -->




<?

terminate();
?>
```
So in my template.php files I have 2 master functions called "begin( $title='' )" and "terminate()".  I tried calling it "end()" but the PHP server didn't seem to like that.

By the way, feel free to use this as a template for your own pages.


----------



## uoba (Oct 19, 2003)

Thanks arden. May give it a test.


----------



## Claruz (Nov 2, 2003)

Smarty is a great template engine for PHP. It saves so much time when working with dynamic pages. If you have pages mainly built up of content processed by PHP this is a lifesaver!

Check it out: http://smarty.php.net/


----------



## uoba (Nov 2, 2003)

Great thanks Claruz, will have a look (would rather do it manually, but this'll help out by looking at how it works)...


----------



## mdnky (Nov 3, 2003)

I use Dreamweaver, and could care less if it renders in design mode or not.  All I use it for is it's code coloring and file management abilities when dealing with XHTML & CSS.

MX2004 trial is much faster than MX on the Win platform, and seems the same for me (maybe a bit faster actually) on my Mac.


----------



## uoba (Nov 3, 2003)

MX 2004 seems hella slow for me, even in code view... have ordered BBEdit 7 for it fantastic code working.


----------



## Claruz (Nov 3, 2003)

I use ProjectBuilder for HTML coding. It's just great to have everything in one window. I also downloaded an extra for PB that gives me colour coding in HTML and PHP! It's as good (if not better, with the project view) as BBEdit and it's free  Nothing against BBEdit, I have BBEdit lite and love it, but I can do what I want for free with PB.


----------



## Arden (Nov 4, 2003)

Hehe, I use SimpleText. 

Here's the code for your template:

```
<?php
function begin( $title = '' )
{
?>

(Put all of your HTML that will go before your content here.)

<?php
}

function terminate()
{
?>

(And this, of course, is the space for your HTML after the content.  Like for your </body> and </html> tags.)

<?
}
?>
```


----------



## toast (Nov 4, 2003)

Mr.K  Yeah, I know, but I don't use the template system, I just use my own code. I don't either use those #thingees, I don't really need them.

As for PHP, I like the moethod described here. In fact, either you're geniuses, either you're copying and pasting from an old ALA article about PHP publishing. But the fact is, my website is static, hard-hand-coded, just like Zeldman, just like Owen Briggs. And I love it like that, I can read my code, I don't update my site so often (a dozen of lines per week, no more).


----------



## TommyWillB (Nov 8, 2003)

I use PHP includes for my header/footer and right-nav... vs. any sort of BBEdit HTML template... The individual pages are only the content of that page.

The right nav has a fair amount of PHP logic in it to make sure it shows the right thing.

None of that CSS or other fancy stuff on my site... It's all basic HTML  circa 1999. Tables all the way baby!


----------



## TommyWillB (Nov 8, 2003)

toast said:
			
		

> I personally use Find & Replace in BBEdit, which has a multifile find/replace capability.
> 
> Eg: I want to change my copyright date in my whole website.
> 
> ...


I got tired if doing find/replace on my copyright years ago... That now "magically" happens for me when I update a page.

You can argue which copyright format is "correct" for the Web, but I have my copyright in the format &copy;(year my site started)-(year this page was last updated)... so any page that has not been updated in 2 years will be &copy;1995-2001

The php code I use is like this:
	
	



```
// This is in my header include	
$FullUnixPath = $HTTP_SERVER_VARS['SCRIPT_FILENAME'];
.
.
.
// This is in my footer include
$FileChangeUnixTime = filectime($FullUnixPath);
$FileChangeCopyright = date("Y", $FileChangeUnixTime);	
.
.
.
// This is my HTML copyright... which is also in my footer include
&copy;1995-<?= $FileChangeCopyright ?>
```


----------



## TommyWillB (Nov 8, 2003)

uoba said:
			
		

> I suppose using the #bbinclude becomes another proprietary bit of code again though? Just as DW.


Not to mentione the fact that you still need to regenerate each/every page when this include changes.

UHG!

Don't get me wrong. I LOVE BBedit and have been using it since version 2.x in 1994. It's find/replace is amazing. I love that it can do it, but always feel like I've done something wrong when I have to.


----------



## Arden (Nov 9, 2003)

I would design sites like Toast if I didn't need a uniform look across all pages, but once I start delving into the templates it becomes a MAJOR pain in the attitude to have to modify _every single f*cking page_ to get them to look the same.  Hence why I jumped on the PHP provided to me in a thread on this site, no less. 

Tommy, I can definitely see how you can improve your site while keeping it looking the same by using XHTML/CSS instead of tables.  One thing I like about Netscape is the ability to push Cmd-E (which is View Source in IE) and open a page in Composer, which gives a visual breakdown of the layout, including showing the divisions between tables... some stuff I would keep in a table, like the picture frame, but most of that I would throw into div's and align with CSS.

But that's just me.  You can make the choice to let your pages take a long time to load on other people's browsers and cause yourself more trouble to manage your layout.


----------



## TommyWillB (Nov 9, 2003)

arden said:
			
		

> ...Tommy, I can definitely see how you can improve your site while keeping it looking the same by using XHTML/CSS instead of tables. ...


I actually started, but quickly realized I didn't totally know what I was doing and it was taking much longer than I hoped.

I haven't really restarted this effort, but here is how far I got: http://www.jeffntom.com/accessable_index.php

(the page actually repeats twice. The top is the layers/css one, the bottom is the old table one for comparison...)

What I have so far certainly is NOT less code than the table version. Also I had MORE luck getting the table version to be stretch (i.e. %-based) than the CSS one... (Again, this might just be because of my limited time spent with CSS vs. my many years with plain ol' tables.)

...oh yeah... And the CSS one has some very serious differences in Safari, IE, and Mozilla Firebird... I never even got to the point of checking this on a PeeCee...


----------



## mr. k (Nov 9, 2003)

css is hard to learn, I agree.  And my guess is that it's a lot harder to learn if your coming from a table mantra.  A great book that I haven't read (just a few parts, I got it from the library bu never finished it) is jeffrey zeldman's designing with wen standards.  He goes over everything you need to know about xhtml and css, and on top of that he shows you how to turn a table based site into a css site.


----------



## Arden (Nov 11, 2003)

Well, the CSS part looks much better (and probably closer to what you want) in NS7, but in IE5 it stretches too far.  This is probably from your use of "width:95%", especially with no "position:" attribute... I'd say use "margin-right: 5px" or something to line the right side of your content against the scrollbar.

I also got this PHP error in both browsers: "Fatal error: Call to undefined function: cell_background() in /Library/WebServer/Documents/includes/global_footer.php on line 9"  Something to investigate.


----------

