SmartFAQ 由 The SmartFactory(https://www.smartfactory.ca)开发,它是 InBox Solutions(https://www.inboxsolutions.net)的一个部门。

我该如何学习开发自己的主题?
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 (http:www.zend.com) or PHP Accelerator (http:www.php-accelerator.co.uk). 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 {}, {{}},, 等.* if/elseif/else/endif 结构可传递至 PHP 解析器,因此 {if ...} 表达式语法可以非常简单或复杂。* 允许无限嵌套部分、if 等。* 可以直接在模板文件中嵌入 PHP 代码,尽管由于引擎自定义程度极高,这可能是(而且也不建议)不必要的。* 带有内置缓存支持* 随意模板来源* 自定义缓存处理函数* 插件架构 请参阅以下 FAQ 和相关链接(点击此处)


评论归作者所有。我们不承担其内容的任何责任。


Login

Who's Online

282 user(s) are online (21 user(s) are browsing XOOPS FAQ)


Members: 0


Guests: 282


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Did you know ?

You can set the page's redirection's delay

Random question

How do I change the password for a site?