SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    Jed.
    Posts
    243
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Separate design from codes

    Hello guys/gals,

    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.

  2. #2
    SitePoint Addict
    Join Date
    Feb 2007
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like kyberfabrikken said I would reccomend using Smarty, or perhaps creating your own templating system to accomodate what you want.
    Have a good day.

  5. #5
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First of all, cuberoot wtf are you smoking and can I have some ...

    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.

  6. #6
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,014
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    imho smarty adds too much baggage, css is just as good if not better
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  7. #7
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,804
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    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.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  8. #8
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  9. #9
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

    good luck.

  10. #10
    SitePoint Zealot
    Join Date
    Sep 2010
    Location
    Brighton, UK
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

    It's a nice clean way to do things because you get full separation between roles. You have your actions, your data and your display. It's similar to the way we use Javascript, HTML and CSS in the front end to give us separation between roles.

    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.

    http://en.wikipedia.org/wiki/Model%E...0%93Controller

    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

  11. #11
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    goldfidget - this thread is more than 2 years old. I'm thinking that the original author probably made his mind up by now.

  12. #12
    SitePoint Zealot
    Join Date
    Sep 2010
    Location
    Brighton, UK
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken View Post
    goldfidget - this thread is more than 2 years old. I'm thinking that the original author probably made his mind up by now.
    Oh my, oops.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •