Page 2 of 2
Posted: Wed Jun 05, 2002 10:14 am
by zorka
user: i want to make a webpage for my department
admin: ok, here are the templates you have to choose from. you can change the content, but you can not modify the layout or the color scheme.
user: ok. but i want to make this line bigger, and red and flashing.
admin: sorry, that is not available in these templates.
In a true CMS system the admin would simply give the user access to edit the page and review his changes after they were made. If the admin had done his homework the user would already have access to create and edit pages for his department. If the user shouldn't have acess to modify the page then the user should contact his department head.
Some of you know that I work for a company that has built our own PHP application framework which separates logic and html called
http://www.logicreate.com (some of you may not). Here is how the LogiCreate system handles this separation of templates and logic.
This is what we call the "welcome module". It's job is for learning purposes and can be changed to fit ones needs
Code: Select all
<?
class welcome extends FuncMapAuth {
var $presentor = "htmlPresentation"; // presentation handler
function run(&$db,&$u,&$arg,&$t) {
$tї"time"] = date("h:i:s");
// choose your template
$arg->templateName = 'main';
// grab something from the Database
$db->queryOne("select name from users where username='$u->username'")
// pass the name to the template
$tї'name'] = $db->Record;
}
}
?>
In the system, anything passed to "$t" is passed to the template. Here is an example of the template which is called "main.html":
Code: Select all
<h3>Hi <?=$tї'name']?></h3>
The current time is: <?=$tї"time"]?><br><br>
Thank you <?=$tї'name']?> for visiting our site. We hope you will come back to see us later.
You'll notice in the above "template" it is simple text and HTML. Anybody that knows HTML can edit this and be simply told which "PHP TAGS" to drop in the template when they are doing the design layout. This separation allows a developer and a designer to work at the same time without intervention. If you want to know more about how this system works and is used, AIM or YIM me offline, there is no need to clutter up the forum with commercial rhetoric as I just wanted to show an example of how templates can be used in a framework or CMS instead of what is currently out there.
--ZorKa
Posted: Wed Jun 05, 2002 8:54 pm
by gotDNS
- Remember kids, much of HTML is supported by most browsers, and since PHP is parsed on your server, do everything you can in PHP
- Note to people that speak of 'hackers' as 'cracking' things.
"Hackers build things, crackers break them."
- Eric S. Raymond
Posted: Thu Jun 06, 2002 12:21 pm
by NetDragonX
lol - all this talk about PHP vs. JavaScript... well a suggestion for you:
Use
both JavaScript
and PHP in your form validation.
That way, if a user has JavaScript disabled... you can always have server-side PHP cover validation. Also note that if they do have JavaScript enabled, the PHP validation shouldn't bother the process at all. So it's a win-win situation.

[/i]
Posted: Thu Jun 06, 2002 8:43 pm
by sam
There is no such thing as pointless php. If it is the quickest and simplist way to get the job done, use it. Enough said.
Cheers Sam
Templates are the base of php.
Posted: Sat Jun 08, 2002 11:50 am
by phphead
most pointless? PHP template engines....*sigh*
now, php started as a perl based template parser. Before the zend rebuild that is all it was. dont go ridiculing template parsers because of their pointless stupidity.
Posted: Sat Jun 08, 2002 1:54 pm
by jason
Template engines are good.
Building template engines out of PHP that essentially create a scripting language of their own (like Smarty) are overkill.
Posted: Sat Jun 08, 2002 1:58 pm
by hob_goblin
most useless use:
kids who get a server with php, but only use 1 or 2 premade php scripts...sure its nice to use other peoples work, but you have to come up with your own stuff sometime..
Posted: Mon Jun 10, 2002 7:31 am
by dkode
I have started to use Smarty Template with PEAR DB about 2 weeks ago. So far it has proven to save me alot of time/effort
I beleive with designer like myself that are developing multiple websites at once. These template systems prove to be very useful and effecient.
I can quickly and easily create a CMS for a client versus code one by hand which I used to do and would take 2+ days. Using Smarty Template I have gotten that development time down to 2-3 hours instead.
I think for certain people template systems will be more useful. I am one of those people that it helps me greatly improve my effeciency. The sites I do use it on arent getting globs of hits but thus far I cannot tell a difference at all in load time.
Actually, if I have caching on (in most cases) the execution time is actually very sped up because there is no need to redundantly access the database.
Theres my 2 cents.
