eeetc — 2008-11-11T02:31:31-05:00 — #1
Can anyone point me in the right direction. I want to make small CMS or let's call it developing a new website but I want to separate code from design completely.
How do you guys/gals go about this?
Anything in this regard is great. I will read.
cuberoot — 2008-11-11T06:04:13-05:00 — #2
There are no gals on this forum. They're in the kitchen making us programmer men some sandwiches and ironing our shirts. Thanks be to zeus, this forum is still untouched by any of those crazy postmodern feminist ideals.
And since you brought it up, you ought to come to one of our naked men in the woods retreats, where we all get naked and throw each other up in the air using rugged outdoorsy quilts. And the best part is: no women allowed! That's right. A real manly getaway.
But seriously, google "passive view". The basic idea is that you have a script that sets up a bunch of variables, picks a template, and fills it in. Not very complicated obviously, but it takes some discipline to pull off. It's just too easy to put stuff into a template. In fact, a lot of people don't know this, but the last temptation of Christ was actually putting SQL queries into a template.
Beyond that, you've been rather general in your description of the project. You'll probably get more helpful input if you provide more specifics.
kyberfabrikken — 2008-11-11T09:29:13-05:00 — #3
Cuberoots weird fantasies aside, it sounds like you need a basic separation between controller code and template. You need to decide on a template engine, and unfortunately there is no de-facto standard choice. The closest you'll get to a standard is probably Smarty - Loved by some, and loathed by many more.
darren884 — 2008-11-11T14:26:37-05:00 — #4
Like kyberfabrikken said I would reccomend using Smarty, or perhaps creating your own templating system to accomodate what you want.
imaginethis — 2008-11-11T14:46:36-05:00 — #5
First of all, cuberoot wtf are you smoking and can I have some :D...
Second, EEEtc... separating code from design is a rather vague description for someone looking for help. I doubt you bothered to search the forums for this topic. I remember reading posts about this very issue over 2 years. Just search and sift through what information is already on the forums and I'm sure you'll find several answer's to satisfy your fancy.
spacephoenix — 2008-11-11T18:00:36-05:00 — #6
imho smarty adds too much baggage, css is just as good if not better
felgall — 2008-11-11T20:07:27-05:00 — #7
CSS can't separate the code and content layers, it can only separate the content and appearance layers.
While there are different languages for the client side layers - behaviour, appearance, content - there are not separate languages for all the further layers server side - content, code, database etc. - and so you need to make a conscious decision to actually divide up the code into separate modules to represent those layers if you want to make maintaining everything easier as the whole thing grows to contain huge numbers of pages that need to use common coding layers etc.
berislavlopac — 2008-11-12T01:51:00-05:00 — #8
xtrem3 — 2008-11-12T12:08:23-05:00 — #9
like others, i feel that a 'template engine' is overkill. PHP is essentially a template engine, so why make another template engine on top of an existing template engine? BUT! for the sake of learning how to separate business logic from presentation logic, i'm going to suggest using a template engine (i.e. smarty). using an existing template engine and adhering to conventions will help you better understand what constitutes presentation logic and what doesn't. once you can make this distinction, you will not only be able to drop your redundant template engine for plain PHP, but you'll also be a much better programmer.
goldfidget — 2011-01-04T17:48:40-05:00 — #10
Hi EEEtc, I could be way off beam here but it sounds like you're talking about an MVC (Model View Controller) pattern.
It works like this. Your web request comes in and gets routed to a controller written in PHP or whatever. The controller goes to the database and pulls everything it needs creating a model, which might be a hash or an array or a PHP object or whatever. Then the controller passes the model to a template View which renders the page.
You can swap out the view layer if you need to reskin the page or something, change to a different templating engine or just ship out XML or JSON for whatever reason.
Codeigniter is a good PHP framework, beyond that you could try Rails3 or Django. Hope this answers your question and I didn't misunderstand you too wildly
kyberfabrikken — 2011-01-05T06:39:32-05:00 — #11
goldfidget - this thread is more than 2 years old. I'm thinking that the original author probably made his mind up by now.
goldfidget — 2011-01-05T06:43:15-05:00 — #12
Oh my, oops. (: