Re: [SMARTY-DEV] binarycloud: Tight Integration with Smarty

From: Date: Fri, 13 Jun 2003 00:49:44 +0000
Subject: Re: [SMARTY-DEV] binarycloud: Tight Integration with Smarty
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-1568@lists.php.net to get a copy of this message
> You provide a very good piece of information. Do you > have any references (Code, tutorial etc) for > seperating php code from html using xml+xslt > technology? Well, we're very careful with XSL. XSL is great for certain tasks but I think it's a real pain in the ass for UI (presentation). For that we use smarty :) We do use XML extensively in binarycloud for all kinds of stuff: definition files, configuration, etc. We translate that XML into PHP at build time with Phing and XSL, so the runtime system doesn't have to waste time parsing static XML files to set configuration values - they're just PHP arrays. Using XML for that stuff is great because we can (and do) validate the XML with DTDs at build time. That helps to minimize errors. As far as separating code and presentation... The simplest way to think about it is your code is responsible for building and storing arrays. Your UI is responsible for presenting and providing tools to modify those arrays. The thing I like about smarty is it gives you enough functionality as a template designer to construct what is in fact a very simple application: a set of templates. Because of that, developers don't have to be bothered _too_ much with UI-only information. binarycloud's scale-free presentation class tree (the node tree) is designed to achieve code/presentation separation. In our presentation system (a tree of nodes) each node has a definition files which defines a template (which of course with smarty can be comprised of many subtemplates that are included). Template params are assigned to the node from the XML definition file, and dynamically from within the node. The node can of course override static params set in its definition at any time before the template is rendered. Each node can have children, which produce output (again, each has a template and may have children, etc) - that output of a child node is available in the parent node's template as an id in an array: {$children.id} One advantage to this system is you don't have to repeatedly include the same files in each page template: {include file="global/header.tpl"} ... Template contents. {include file="global/footer.tpl"} With our system, you can use a single 'master' page template: <html> {$children.content} </html> And create nodes with Ids that correlate to the Ids defined in the template which provide presentation. (in the example above, the output in children.content could come from a Forum app, or a CMS article app, or anywhere!) Using this system we're able to build extremely sophisticated, flexible presentation that can be used in many contexts. For example, a "forum" node can detect whether it is the top level node or nested in a tree of nodes, and choose to output XML (if it is top level) or HTML (if it's in a tree). This discussion could easily mushroom, and I'm not sure that smarty-dev is the best place for it. This kind of traffic is welcome on binarycloud dev. Best, _alex

« previous php.smarty.dev (#1568) next »