PDA

View Full Version : Editable Templates


GTB
09-07-2009, 01:46 AM
Hi, I am trying to make a template that will change every page I have created using the template.

I need to change my website often but it would be great if I could just change the template and have all the pages change immediately.

Apart from the editable regions of course.

I hope that makes sense.

Does anyone know of a tutorial I could look at to see how this is achieved, if it's possible at all.

My apologies if it's a stupid question.:oops:

edbr
09-07-2009, 02:32 AM
using includes. if the sections you want, have an include file common to all, then changing that file will alter all without a total update.

GTB
09-07-2009, 03:27 AM
Many thanks for the speedy reply.

Unfortunately I have never heard of "includes"

I will try and find a tutorial unless someone can point me in the direction of one that a five year old could understand.

edbr
09-07-2009, 04:45 AM
easy with php, there are such things as html includes but you will have to see if your server allows them
there very simple, they are just instructions to include the contents of a file at the position entered in the page
in php it would be coded
<?php include('text.txt); ?>
this would then show the contents of your text.txt file

Corrosive
09-07-2009, 07:31 AM
Try reading through this...

http://www.dreamweaverclub.com/php-includes.php

GTB
09-07-2009, 01:39 PM
OK Many thanks for that, I can't seem to get it working though.

I have created a folder called includes and follwed your instructions for the menu.php.

I have put the menu.php inside the includes folder.

In the menu.php I have:
<li><a href="index.php">Home</a></li>
<li><a href="about.php">About Us</a></li>
<li><a href="products.php">Products</a></li>
<li><a href="services.php">Services</a></li>

I have then created a new webpage called aaaa.html

Inside that I have:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<ul id="navigation"><?php include("includes/menu.php"); ?></ul>
<body>
</body>
</html>

It's not working though because I just get a blank page when aaaaa.html is published.

Can you see what I have obviously done incorrectly ?

Corrosive
09-07-2009, 02:06 PM
Try giving your page a .php file extension rather than .html

GTB
09-07-2009, 02:11 PM
My sincere thanks, it seems to have worked.

The problem I have now is that there is nothing in the Design view of my new page aaaphp.php, is that normal ?

Corrosive
09-07-2009, 02:51 PM
If nothing else, you should get a small 'shield' like emblem where the content will be but you do usually get the content.

It does say in the tutorial that you should be comfortable with hand-coding if you want to use includes. I'd stick by that and say that moving away from design view will only do you good ;)

GTB
09-07-2009, 04:08 PM
Thankyou very much I think I might almost have this nailed.

My last and most crucial problem is that I cant seem to make an editable region.

If I go to Insert > Template Objects > Editable Region it says that Dreamweaver will automatically convert this document to a template.

When I click ok I get a box saying: Name: EditRegion1.

Then on the page I get this:
http://www.thegtb.co.uk/aaaphp.php
(It is the pink area that I would like editable.)

Now I assume I can pull up a file called EditableRegion1 so that I can insert what I need but I can't find it anywhere for the life of me.

Or have I got the wrong end of the stick here ?

DWcourse
09-07-2009, 04:23 PM
I think you're misunderstanding templates. They are used as the basis for new pages with the same structure. In the new pages only content in editable regions of the template can be edited independently. For other areas you edit the template and the changes "flow" to the pages based upon the template.

An editable region is created in a template so that, on pages made from that template, the region is editable. That's all it does. If you convert your page to a template a copy of it will be saved in the Templates folder with the .dwt extension. You can then use it to create new pages but not as a page in your site.

Editable regions don't created include files which is what you seem to be confusing with templates.

Corrosive
09-07-2009, 04:24 PM
Or have I got the wrong end of the stick here ?

Yes, afraid so. The idea of using includes is that you can pull your consistent site elements into the page put create a new page for each bit of content. You can use templates and includes together but I never have. One or the other for me.

GTB
09-07-2009, 05:34 PM
OK I am sorry about this.

What I want to create is a page like this http://www.thegtb.co.uk/a1test.html that is common to all the pages in my website apart from the red links down the middle, which I will need to have editable for every individual page.

What I need to be able to edit in the includes.php is the Black and White names down the right hand side and the menu buttons down the left hand side.

It is a members clan for gaming and members change often so when I add a name to my menu.php It would then save the hassle of updating 100's of pages individually.

(But obviously I dont want every page to be the same, as some pages have photos, some videos etc etc)

I really am sorry for sounding like a halfwit here, I really thought I was getting somewhere with this.

I have a feeling that I will be directed toward the first reply of this thread, LOL.

Many thanks

Corrosive
09-07-2009, 05:44 PM
Then make your header/banner bits and the left and right column contents as includes and then the bits in the middle as plain old HTML. So each page will look something like...

<div id="header"><?php include("includes/header.php"); ?></div>
<div id="left"><?php include("includes/left_links.php"); ?></div>
<div id="main">This is where your 'editable' content goes</div>
<div id="right"><?php include("includes/right_links.php"); ?></div>

Then create three includes files to have the constant content as referenced in the code.

GTB
09-07-2009, 07:52 PM
LOL, I ended up with this, http://www.thegtb.co.uk/aaaphp3.php but it looks like there is progress being made.

I will keep playing with it then come back crying for more help after I have strangled my wife or anyone else that interupts my train of thought.

FYI It's supposed to look like this http://www.thegtb.co.uk/a1test.html

Many thanks.

GTB
09-07-2009, 08:54 PM
Oh I've managed it, many thanks for your patience and help guys.

This is what I was after http://www.thegtb.co.uk/aaaphp6.php

Thankyou very much :)

Corrosive
09-07-2009, 09:24 PM
I'm glad. I didn't want to see 'local man strangles wife over website' on Points West tomorrow night! Lol

GTB
09-08-2009, 02:12 PM
OK I think I have most of what I need pretty much nailed now, thankyou for your help.

However....

Is there a way of making www.thegtb.co.uk (http://www.thegtb.co.uk) point to index.php instead of index.htm

I can't seem to find the area where it can be changed.

Looking at the lynda.com tutorials it's telling me that it has to be either index.htm or default.htm

If that is the case, how would I make my home page use the includes if I can't change the file to index.php ?

Hope that makes sense.

Many thanks.

DWcourse
09-08-2009, 02:49 PM
Most servers will use index.php if not index.htm or index.html is present (usually there's a heirarchy). Try it and see. If not you should be able to configure it on your server.

Also, you'll probably want to add a 301 redirect in your .htaccess file to make sure that you don't lose any existing links, etc.

GTB
09-08-2009, 03:36 PM
I can't find anywhere in dreamweaver that says "heirarchy" although it is annoying me because I know I have seen the word somewhere.

Also, I don't know how to configure the home page to be index.php.

I will look into 301 redirects as soon as I find out what they are, LOL

DWcourse
09-08-2009, 03:52 PM
Heirarchy (at least this kind) isn't in Dreamweaver. I'm talking about how your server determines which page to show it you don't include a file name for a directory. It's usually something like:

index.htm, index.html, index.php

So, in the absence of index.htm and index.html, index.php will be used as your default directory page.

To test it, rename or delete your existing index.htm page and see if the index.php page shows as the home page (possibly after a browser refresh).

A 301 redirect is a bit of code that goes in a file called .htaccess on your server that tells the server, "if a request comes in for page X give them page Y instead." See http://en.wikipedia.org/wiki/URL_redirection and then ask for help. It can be (very) tricky.

GTB
09-08-2009, 04:52 PM
To test it, rename or delete your existing index.htm page and see if the index.php page shows as the home page (possibly after a browser refresh).

I tried deleting index.htm and had the index.php there waiting to rock and roll, but when I deleted it it just came up as website could not be found.

Hmm, I will keep trying.

Many thanks for help.

I spoke too soon, it works now, don't know why it didn't in the beginning.

I'm all exited now :)

DWcourse
09-08-2009, 05:13 PM
In that case you need a setting on your server changed. You may just be able to tell your server to treat .html pages as .php but someone else will have to help you with that.

Corrosive
09-08-2009, 05:55 PM
I spoke too soon, it works now, don't know why it didn't in the beginning.



One of life's little mysteries no doubt!

edbr
09-09-2009, 02:57 AM
html pages as .php but someone else will have to help you with that.
if you have a lot of links going to www.yourSite.index.html then you could change this using htaccess. i can send you a link if you need it for a online generator but if yhe links to you are to www.yourSite/ then chngig the extecsion wont make any difference

GTB
09-09-2009, 12:27 PM
Many thanks, I am gradually going through the whole website changing every individual page.
It is laborious but I suppose it is giving me the chance to have a good clearout of things that are not needed any more.

The actual site wont look like it does now when I am finished but at least now with the includes i can try many different layouts and have a look at what work best.

Many thanks for all your help guys, I am over the moon.

Corrosive
09-09-2009, 12:31 PM
Many thanks, I am gradually going through the whole website changing every individual page.
It is laborious but I suppose it is giving me the chance to have a good clearout of things that are not needed any more.

The actual site wont look like it does now when I am finished but at least now with the includes i can try many different layouts and have a look at what work best.

Many thanks for all your help guys, I am over the moon.

No problem mate.