|
Posted by Oliver Grätz on 04/20/07 15:39
Harris Kosmidhs schrieb:
> gee...thanks buddy nice explanation. I tried cake but for some reason I
> can cope with all these ready-made frameworks. I prefer to write my own.
Well, I've already reached that point where I have my own framework but
that doesn't mean that I don't use parts of other frameworks.
Technically the most frameworks are only class collections. You can
decide to use some of the classes but not all of them.
A good example is the Zend Framework. It supplies you with an
implementation of MVC but you can decide against using any of this but
still use other parts, for example the ACL implementation to check
access policies. I personally like the routing concept of the Zend
framework MVC parts and use them. As for the View, I have started using
more templates but not for the <head> part of the page because I have a
very good class for this.
BTW, the simplest way of doing templates is this:
ob_start();
include('template_file.php');
$result = ob_get_clean();
The template file will mostly consist of HTML that is mixed with small
portions of <?=$title?> or <?=$street?> code snippets. In this
implementation you must have these ready before the ob_start. You can
also use this inside of an object in some method an then use properties
like <?=$this->title?>. After evaluating the template you get the
resulting string in $result. You can then use this as input in another
template if you want. This is the technique to do hierarchical
templates. The fact that the filename for the include() command is a
string enables you to do theming. Sometimes concepts are just that simple.
And remember: With the __toString() method, any of these variables can
contain an object instead of a string, so nobody stops you from creating
"intelligent" outputting objects.
OLLi
--
Dargo: "If you can be an idiot, I can be an idiot."
[FarScape 120]
[Back to original message]
|