Recent Topics

1 Jul 11, 2006 00:19    

I'm trying to transition a large site from a file based site to a database driven site. The problem is that I don't understand how to use templates with changing layout elements. How do you cope with items that change on a page per page basis, such as setting a background image on a <h3> tag or including different javascripts for different functionality. It seems like you would have to either build lots of templates or store those changing page elements in the database somehow.

Any thoughts on how I can do this better?

2 Jul 11, 2006 08:00

<h3 class="<?php echo $page_name; ?>">My heading</h3>

And then in your css just have something like:

.WelcomePage {

body {
 background:url('/images/bgs/WelcomePage.jpeg') fixed no-repeat;

You get the idea.

Is that what your looking for?

3 Jul 11, 2006 19:08

Thanks balupton, but I don't think that's exactly what I'm looking for.

Basically, I would like site maintenance and page creation to be easier. I would like the site to sport clean urls ( and have the side navigation, top navigation, and breadcrumbs dynamically populated from the database. I would like the meta data dynamically generated (

So to accomplish this I assume that I need to use some kind of template engine (ex. plain php, Smarty, or XSLT) to separate my content from my code and database to hold my content. I am aware of the MVC way of doing things (, I like what Tony Marston has done but it is more for a backend structure than a frontend.

So my problem is this:
What if you have a site that contains pages that do not always have similar page elements, how do you cope with that? Usually people can simply define a header and footer include and use that site wide, but what happens when you have a page where you want to include some different javascript or include some different css in the head of the document? My guess is that you would have to build a new template.

Does that make sense? I'm trying to figure out the best way to develop the frontend. Unfortunately there isn't alot tutorials on how to do that.

4 Jul 11, 2006 19:11

Are we talking about with b2evolution?

5 Jul 11, 2006 20:48

No, just general php/mysql web development.

6 Jul 11, 2006 21:03

Ahhhh ok.

Well i'm sure you could find a CMS to handle all that for you.

But i would recomend learning how to make your own :)
If you have a few hours a week to spare, take up a course in php, it's a great way to learn.

But if courses arn't for you, then yeh keep posting here and fidling with php every now and then.

Anyway, going by courses arn't avaliable option, heres my suggestions:

1) Having the urls as /site/section/index.php, is a bad idea, as in each file you will be doing;

include '../_header.php';

and so on, gets anoying and is 'bad' design.
You can still have 'clean' urls by modifing you .htaccess file, there is lots of information in this forum about this, or you can just google it.

2) For handling the pages, do something like:

include 'pages/'.$pagename.'.php';

This is if you do not want to fully convert to a database (good for quick jobs, and static to dynamic conversions of small sites).

3) For handling different displays of different pages, just have a if statement in your layout page that detects if it is a special page and applies the changes necessary.
- Refer to bad design mention is note 1.
Using a index.php?page=blah, is much easier as you do not get confused and start making redudant or duplicate code, and your file organisation will be better.
This is good as you can have _layout.php, _header.php, etc, and easily modify them, and changes reflect on all pages.

All my tired mind can come up with atm, hope this is what your hoping for, and i hope it helps.

7 Jul 11, 2006 23:07

Thanks for the help, nice site by the way.

8 Jul 11, 2006 23:11

gman wrote:

Thanks for the help, nice site by the way.

Cheers, although whenever i do something 'new' b2evolution catches up and it's not new anymore, hence why i'm converting everything to plugins (or i'm thinking about it).

Anyway, if you need more help just ask.

Form is loading...