I promised to talk about the theming system, even if nobody gives the slightest fuck about it, so that's what I'll do. [comment]Trufax: Nobody really cares. Ever.[/comment]
The theming system comes packaged as a module, so it could be re-made in a better way by someone else, without requiring any hacking. Which is another brilliant thing about the hooks/module system. But anyway, the ESSENTIAL packagespace theming module works quite simply for other people to use it. Basically all you need to do is this: [code] global $t; //Access the global theme instance. $t→loadTheme($themeName); //Optional, if not used, the default theme gets loaded. $t→openPage($pageTitle); //Automatically creates the header, menubar and everything. echo("This text is inside the content area"); $t→closePage(); //AUtomatically closes the content area, creates the footer and closes the document. [/code] That's all. I am not making this process completely automatic because if I did, it would make hacking it extremely difficult and it wouldn't allow for text-only output or API output, which is something that can be quite profitable to have. Another thing that it handles automatically is output compression and header-ahead. With the latter I mean that it automatically flushes the output once the header is written, which sends it to the client, decreasing the time the user has to wait to see a page.
Now, how is a theme made? A theme package [i]requires[/i] the following files: config.conf header.php footer.php (The latter two can be named whatever you want though) Additionally you can provide a folder for images, css files and javascript files that will get automatically loaded. A sample config file would look like this: [code] name:Super Special Awesome Theme version:1.0 author:Shinmera description:This is the BEST THEME. images:images header:header.php footer:footer.php css:awesome.css [/code] The name, version, author and description are optional parameters you can use to be displayed in the theme manager. Themes can easily be installed. You simply need to place a folder with all theme files into the themes folder in the root directory.
Now for the actual process in more detail. What happens during the whole process?
1: The global_header file is included. It does the following: –1: Write the html page to be compatible with XHTML 1.0 transitional, including character set and all. –2: Open the page
block with the specified title for the title tag. –3: Link all necessary CSS files required by the theme. –4: Link the jQuery library. –5: Include the meta page that describes various meta tags that may help increase SEO. –6: Close the block and open the block. 2: The header file specified by the theme is included. This usually writes the page header and opens a content block.3: The module writes all the content it needs to write.
4: The footer file specified by the theme is included. This usually writes the page footer and closes the content block. 5: The global_footer file is included. It does the following: –1: Link all the javascript files specified by the theme. –2: Link the jQueryUI library. –3: Close the
block. –4: Close the block.6: The module can do whatever it wants, except write to the output.
After that all the functions unwind and it all falls back down to decoder.php, which then induces a final flush of all data, closes the database connection and lets php die.
The inclusion of the jQuery and jQueryUI libraries seems a bit wasteful at first, but it pretty much levels out in the end. First of all, jQuery itself is extremely useful and is used almost everywhere I write js code. Second of all, jQueryUI provides a load of extensions for jQuery that make certain actions very easy. Third of all, they are linked to static google api URLs, which means they get downloaded over a CDN and can be/probably already are cached by the browser, so the speed impact is pretty much zero when it comes to loading files. Sure, the browser needs to execute the js as well, but that's almost negligible nowadays. For extreme performance, you can always write your own Theming module or a specific page (As the Purplish (Chan) module does f.e.).
In the end, the Theming process isn't very complex and really nothing fancy, so I don't really pride myself with it. But, it's still a relatively good system and easy to use. So ya.
That's it.
Oh I forgot to mention: The Theming system triggers a couple of hooks that other modules can attach to, to provide better extensibility. These hooks are: header-begin, header-end, body-begin, body-end. Of course, you can always also trigger a hook from within your theme header/footer.
Written by shinmera