I just started out with a new site and I decided to use DOMImplementation for building the complete site.
What do you think about this, is it fast enough? I expect it to be quite a bit slower than the basic print method. I prefer the DOM one because it allows greater flexibility when building the final output, not to mention the more error-free XHTML. Anyway, I would like to have some speed comparision at least.
Could you recommend me any (perhaps completely obvious) ideas to keep the PHP code clean (i.e. keep the HTML on a minimum level)?
You could have a Widget class that has methods like checkBox, textArea, and the like. Your View/Controller base class defines a function addContent($aString). When you build a form, you say stuff like
$builder = new Widget();
$this->addContent($builder->textArea("Description", $description, 5, 100);
$this->addContent($builder->radioGroup("Platform", array("FreeBSD", "Linux", "Windows"), $platform, 100);
where
public function textArea($name, $value, $numLines, $width) {...}
public function radioGroup($title, $nameArray, $selectedValue, $width0 {...}
// etc.
Your forms then don't know anything about HTML then: they operate strictly with UI components. Subclasses of your Widget class might produce HTML, or whatever.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With