Re: Re: Separate PHP Code From HTML || Pros & Cons

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I  dont think its so bad.

What I do is keep the PHP and HTML seperate, but in the same file: php on
top, html in a here document at the bottom. I COULD go one step farther and
have the HTML in a seperate file, but I just dont see the point.

  td

On 10/7/06, Thiago Silva <thiago.silva@xxxxxxxxxxx> wrote:

On 10/7/06, sit1way <sit1way@xxxxxxxxxxx> wrote:
>
> Hey all.
>
> This presents problems in that any updates I make to the CMS only affect
> the
> site I'm working on.  So, while working on one site I may make changes
to
> the CMS, changes that improve the app., but other older sites do not get
> updated -- it's OK now, but things are getting sloppy ;--)
>
> I would dearly love to have a base CMS repository that all sites would
> draw
> on, extending the base CMS in the event that a particular client has
need
> of
> customization.  Some combo of Linux and Apache would do the trick; e.g.
> PHP
> requests for any of my sites would point to say, "/home/cms/includes/"


Are you using a version control system? Using one and, maybe, reviewing
your
architeture for code re-use might help in this matter, I think....

Now, the other issue I'd like to address is separating PHP code logic from
> site HTML.
>
> (...)
>
I've often heard the mantra, "separate code from HTML", but it seems
> ridiculous at times to include tiny HTML snippets that can easily be
> echoed
> out, or stored in a variable.  Smarty goes to the extreme in separating
> code
> from HTML, but looking at their templating system, I wonder what's the
> point?  Is it the end of the world if you've got a few choice if, then,
> else
> statements in your HTML templates?



Is of my understading that this mantra is about intention in the code.
We have a framework written in PHP that also uses PHP as template
language.

I mean, we have source files that define components, where we use PHP to
process the data normally (declaring classes, using DB, etc), but there
are
also "snippet" files were we have HTML + PHP.

The special case here is that the snippet files have a couple of arrays
with
data (created and offered by the components) available and their only
occupation is to process output: no DB access, no class declaration, no
file
inclusion, no socket connection....all they have to do is render HTML (or
whatever) with the data they received. The most complex things we have in
snippet files are small functions where recursions help displaying  some
widgets. Everything else are loops, decision strucutres and lots of
print/echo. Simple source files, in the end.


Thiago Silva




--
Publish technical articles @ skilledwords.com and get 100% of the
ad-revenue!
http://www.skilledwords.com

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux