View Full Version : Taking PHP further
skinme!
11-17-2002, 11:24 PM
This is not really a question, but rather (I hope) an impetus for a discussion.
Basically, I want to code a site from scratch in PHP whereby the design element and the content element is completely seperate.
What do you think / experience to be the best approach? I was tending down the lines of XML to store data (with expat in the PHP). It seems an over complicated way to go about it. What are the other approaches and their pros/cons/particulars?
whammy
11-18-2002, 04:30 AM
If you want to keep it completely separate, I'd go for ASP.NET. ;)
(hehe, that's the first time I've been able to say something like that!).
firepages
11-18-2002, 01:36 PM
Its a common misconception with JAVA heads especially and .NOT 'ers as well that seperation of presentation and logic is not possible with PHP when of course thats completely untrue (the same goes for PERL).
PHP gives you the ability to do what you want in (and this is the bummer) is far too many ways , & there are so many implementations of templating systems and the like that its hard to recommend 1 or any... I dont use templates, its been said that PHP is a templating language and that abstracting that further is a waste of resources and in part I agree, many don't ;)
From a simplistic templating angle you could look at creating your own tags ala CFM or JSP so the designer can write say...
<html>
<body>
..... blah
<form php_id="loginform">
.... more blah
<table php_id="member_table">
...more blah
</body>
</html>
etc and you then parse the page with PHP substituting the php_id stuff with your code.
Of course thats terribly innefficient ... but much of the web works that way already and with a bit of page caching etc its manageable, in fact all templating systems are inefficient but thats life , I hear that smarty (search at sourceforge) is one of the better ones, I found it overly complex and confusing for designers and coders alike.
XML/XSLT suffers again from the performance hit of the translation and which XML parser to use is a hard descision as none are perfect, + not all hosts have the sablotron available for transformations though improvements in PHP XML are in the offing.
Sadly the first thing most of us learn about PHP is how easy it is to mix it in with HTML, and I still do on a daily basis because I design and code and most of my projects are on a scale to not require collaberation etc, I do though have larger projects where I have to consider others :( , in those cases I try and keep PHP out of the HTML as much as possible by pre_building as many page elements as I can limiting the amount of PHP that designers have to cope with to simple echo's and I have found that whilst many dont understand exactly what
<?=$login_form;?>
is or means.. they have no issues using it in the knowledge that a login form and form controls will appear wherever they put it utilisuing any styles they have previously supplied.
no answers there I am afraid just my rant.
druffus
11-23-2002, 05:43 PM
I use a great templating system on my site www.brokenbindings.com. The php code is completely seperate from my html. I have .php files and .tpl files for everything. The php parses the templates and fills in variables with whatever I need.
It is great to seperate design and logic and can easily be done with php. Can't lose in my opinion and with the type of language php is, it makes everything easier.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.