You are here: Re: PHP Web Controls « PHP Programming Language « IT news, forums, messages
Re: PHP Web Controls

Posted by Mike P2 on 05/02/07 19:56

On May 2, 1:02 pm, Areric <josh.schr...@gmail.com> wrote:
> Hey all,
>
> ASP.NET has a concept of a user defined web control, where a person
> can implement their own web control and override the render method to
> write out html for that control.
>
> I was wondering, in general, do people ever follow a similar pattern
> when writing PHP4+ code? By which i mean, i could write a WebControl
> base class and a TextBoxControl that inherits from that, then in my
> html markup instead of writing out the input tag by hand i could call
> textBox->render().
>
> Up to this point i have simply hard coded all the html myself and then
> inserted echos into the appropriate places. However, im wondering if
> this might be a better approach then having such "messy" html.
>
> Any thoughts? Opinions?

This is the only thing I miss when I code PHP. ASP.net makes template
logic so much simpler without a few extra tons of code. In PHP, we can
use libraries such as Smarty and others that work similarly to achieve
something similar. In fact, this method at times allows more control
over what goes on than ASP.net controls do.

Here is Smarty template engine, a powerful templating engine that is
basically setting the standard for other engines:
http://smarty.php.net/

And here is TemplateLite, which works almost exactly the same as
Smarty (you barely have to change any code when switching between this
and Smarty), but is better performance-wise. They try to make it so it
can work with the same template files as does Smarty, although
accessing the superglobals works a bit differently. Also, when you
make your own functions, modifiers, and blocks (similar to controls),
the naming convention of the functions is a bit different.
http://templatelite.sourceforge.net/

I think it's good to work with templating engines that work like
Smarty because spin-offs often try to be compatible with it. This way,
if you ever want to switch which your site runs off of, it shouldn't
be too hard.

Mike PII

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация