SmartFAQ is developed by The SmartFactory (, a division of InBox Solutions (

How do I learn about developing my own theme?
XOOPS theme developer's guide overview As with most modern sites, the Xoops default theme (which is now powered by Smarty) has a 3 tier model: 1. Module/Block Template Snippets (Powered by the Smarty Engine with content tags into which content is generated) 2. Design Templates - controls design & general structure (called a 'grid' by designers and such) 3. CSS File - This is where the actual design is.... Notice how we call them "Template Snippets" because you almost never create a single template for a complete page, but rather small pieces of html code, which are "connected" to each other like Lego blocks, which means it is now possible to create complex and interesting site structures (Although it is generally recommended to keep a simple layout, for easy maintenance). A good example is the way blocks have their own template. The various blocks on the site are generated with their specific title and content, using the block template, and the result is in turn generated into another template which is higher in the hierarchy. Of course this method means you can not have a different design per block - all the block templates in your site will use the same theme block template, but perhaps this will be made possible in a future version of Xoops. To sum things up a bit for this overview, if we were to look at the order in which templates are processed, this is what we would see: 1. Get a list of blocks that need to be displayed on this page 2. Generate the html for every block, and keep the buffers 3. Stick this html inside the theme block template 4. Concatenate all the buffers for the left side blocks into one single buffer 5. Concatenate all the buffers for the center blocks into one single buffer 6. Concatenate all the buffers for the right side blocks into one single buffer 7. Render the main theme template of the site, passing the buffers previously prepared, into the template When you understand how this system works, it is easy to see how Xoops caches blocks by simply saving the result of the template rendering in a file (the buffer containing the html result from rendering a smarty template with variables from xoops), instead of pulling the data from your db for every page access. This mechanism dramatically improves the system performance, and lowers the cpu usage, resulting in fast page loads. What is Smarty? Smarty is a template engine for PHP. More specifically, it facilitates a manageable way to separate application logic and content from its presentation. This is best described in a situation where the application programmer and the template designer play different roles, or in most cases are not the same person. For example, let's say you are creating a web page that is displaying a newspaper article. The article headline, tagline, author and body are content elements, they contain no information about how they will be presented. They are passed into Smarty by the application, then the template designer edits the templates and uses a combination of HTML tags and template tags to format the presentation of these elements (HTML tables, background colors, font sizes, style sheets, etc.) One day the programmer needs to change the way the article content is retrieved (a change in application logic.) This change does not affect the template designer, the content will still arrive in the template exactly the same. Likewise, if the template designer wants to completely redesign the templates, this requires no changes to the application logic. Therefore, the programmer can make changes to the application logic without the need to restructure templates, and the template designer can make changes to templates without breaking application logic. Now for a short word on what Smarty does NOT do. Smarty does not attempt to completely separate logic from the templates. There is no problem with logic in your templates under the condition that this logic is strictly for presentation. A word of advice: keep application logic out of the templates, and presentation logic out of the application. This will most definately keep things manageable and scalable for the foreseeable future. One of the unique aspects about Smarty is the template compiling. This means Smarty reads the template files and creates PHP scripts from them. Once they are created, they are executed from then on. Therefore there is no costly template file parsing for each request, and each template can take full advantage of PHP compiler cache solutions such as Zend Accelerator ( or PHP Accelerator ( Some of Smarty's features: * It is extremely fast. * It is efficient since the PHP parser does the dirty work. * No template parsing overhead, only compiles once. * It is smart about recompiling only the template files that have changed. * You can make custom functions and custom variable modifiers, so the template language is extremely extensible. * Configurable template delimiter tag syntax, so you can use {}, {{}}, , etc. * The if/elseif/else/endif constructs are passed to the PHP parser, so the {if ...} expression syntax can be as simple or as complex as you like. * Unlimited nesting of sections, ifs, etc. allowed. * It is possible to embed PHP code right in your template files, although this may not be needed (nor recommended) since the engine is so customizable. * Built-in caching support * Arbitrary template sources * Custom cache handling functions * Plugin architecture Please also see This FAQ and related links

The comments are owned by the author. We aren't responsible for their content.


Who's Online

290 user(s) are online (2 user(s) are browsing XOOPS FAQ)

Members: 0

Guests: 290



Goal: $100.00
Due Date: Feb 29
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Did you know ?

most shared servers are unsafe and enable malicious users to take advantage of world writable folders?

Random question

How do I display a block in the header instead of the banner?