![]() |
design tips?
I don't use Smarty templating engine or any other template framework...perhaps I should...but anyways...here's how I normally design my sites, I know it's kinda "old school" but would like to hear your thoughts and perhaps get ideas on how you guys go about designing sites....
My design, whether it's based on dynamic or fixed width is usually as follows: header.html index.html footer.html The index.html is where all my pages are and the header/footer almost rarely changes. If I do need to make a change, then it affects all other pages since they all call the header/footer pages. There are 2 issues I have with this design though. 1) Since I use Dreamweaver as my WYSWIG, the CSS is called from the header.html file. This means that when I am working on the (main body) page, I don't actually get to see the CSS affects since the page doesn't know about it. Only when I upload the page does it call the "header.html" file and the CSS is used. I can though call the CSS temporarily within the file while working on it, but then I'd have to remove it so I don't call it twice...it's just a pain though. 2) If I want to change the overall design of the (body), this is where it causes a problem, because I would have to go through ALL the pages to change the whatever new style I come up with... Anyways, this was my method and has always been my method to avoid using frames. I'm not sure if "frames" is even used anymore in today's designs?? Is it taboo?? So my question to you guys is, what are your techniques when it comes to overall design of a website? How do you design a site in which, if you come up with a new design, you don't have to go through numerous pages to update them? |
I use a Template Class - basically, I can have an index.html file with php include for header and footer inside, parse variables to it, have while loops if needed. I always design a page in html, once it's complete, slide header, index and footer up. Frames - I never use them, but iframes come in handy :)
Anyway, hope my class will help you: PHP Code:
PHP Code:
idx.html is the template file. Example: HTML Code:
<?php |
Thank you Sam,
I will take a look, I'm a newbie when it comes to OO so it might be a little tough for me to understand how to fully use it... So really, your design is kinda like mine but taken to another level, where the header/body/footer is all within the class and then you just call that class for any page you make right? So let's say you had these 5 pages.. index.html, support.html, about.html, contact.html, services.html They would just somehow call that one class and they inherit whatever style you initially designed? |
Well, lets say I have index.php - I define some variables (template filename and content) and send that to the class - class handles it from there, if I want to include a header file, I define that in the template class.
In my header I can also define variables the same way I do in the page that includes it does. CSS link is in the header. |
PS. VIEW_PATH is a define in the class - so you;d need to change that to the dir that contains the files.
|
Example of header.html - also placed in the template dir.
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
Interesting.....
Do you think Smarty and those other templating engines work relatively the same process? I'll play around with your code and put something up for you to see.... Thanks again! |
Yep, but smarty is quite large, has lots of functionality that I don't need. But it has some nice addons. This is just nice and simple.
|
Quote:
That's what I like....I think I understand your PHP class code.. Hopefully I can whip something up real quick in the next few hours..... I'll just leave out the DB part since I don't need to connect to anything right now.... My current method must really be old school!!!!!!!!! |
Old school you might say - template files are easier to work with, but PHP in itself is a templating script. There's nothing wrong with your method, and it's the 'fastest'. But this just makes it a tad easier.
|
Quote:
Would you say this is how you are setup? Path Info: /www/ = main www directory that holds your calling pages /www/images = images directory /www/template = template files and php class files -------------------- /www/template/header.html /www/template/main_body.html /www/template/footer.html non-public folder /whatever_directory/db.php = file to connect to DB |
Exactly :) ^^
|
A template doesn't need to connect to the database. As it doesn't require ANY resources to parse and display it (I am here referring to CSS - which is the presentational part of an application or a website, but not tied to the template files themselves - and JavaScript - which is the functionality given to the client by the application as a whole, not by the template files). So, I'd suggest you stick to the purpose, and that's all. Make a connector between a template file and the database (that would be the Controller in an MVC oriented system), and use that to perform operations on the DB, and do other stuff like that which doesn't have anything at all to do with the purpose of templating an application/web site/etc.
|
Quote:
|
| All times are GMT. The time now is 09:58 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0