I am currently involved in a new CMS on Rails, called Rail Frog. This CMS aims to become a so called "engine" for Ruby on Rails, meaning, that you use it as a start for your project.
This post is here, to introduce the conceptual engine, called brickslate, and to explain the reasoning behind it, by explaining the architecture of rail frog and its theme engines.
For Railfrog, we needed a theme system that is clean, well integrated, flexible and all that. Im developing this, a pdf is found on my site, and the project pages are in the Railfrog Wiki.
Note the similarity between this, and PHPtemplate?
However, some differences, that we, using PHP and Drupal, can use to improve Drupals system are:
* Make theme engines modules. After all: they are just that.
* (re-)Introduce a way to avoid code being ran on a server. PHP is insecure. Being forced to "allow your clients to run PHP", just because you want to allow them to install a new theme, is BAD.
* Chunks! chunks!
Chunks: In railfrog everything is a chunk. And no, not only content. Everything. most interesting for us, is that themes are chunks too. Which is how we integrate themes and cache and content. For sake of clarity, let us leave the cache part out of the picture now.
I type a short text: chunk #1 (tagged: area=content)
I upload an image: chunk #2
I add a longer text: chunk #3 (which I want to contain an image)
I have a template/layout: chunk #4
All of them live in the DB:
4:
<html>
<head><title>{{{ print_chunk_detail(2, :title) }}}</title></head>
<body>
<div class="content">
{{{ print_chunk(3) }}}
</div>
<div class="toolbar">
{{{ print_chunk(1) }}}
</div>
</body>
</html>
Chunk #3 would be something like
<div>
{{{ image_tag_from_chunk(2) }}}
</div>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Vivamus sodales malesuada eros. Maecenas ullamcorper. Curabitur vitae tellus. Aenean est dui, pharetra sed, feugiat ac, feugiat non, augue.
Aliquam euismod turpis vitae pede. Quisque dictum lorem at est. Nunc ultricies.
Which, as may be clear, calls chunk 2 and 1 and compiles a page from them. Note that this is very simple, and in real life this concept is much more complex.
As you can see, this chunky idea, is loosely based on nodes. But it surpasses nodes, in that way, that a chunk is meant to contain other chunks. A Drupal node still has no core method to be related to another node.
However, the part that we can use, in Drupal, is what I call brickslate:
Just replace the word "chunk" with "brick" and you have it. Brickslate.
Brickslate would be a PHP template system that uses bricks to build everything up. from ground. Instead of completely explaining what it is, I suggest you read my introduction. In short, however, the idea is as explained above with chunks: Everything, is a brick.
Many bricks (author brick, links brick, taxonomy-terms brick, content-brick) make a post (node). Which is a brick again. Many of such bricks make a list of posts (drupal frontpage), which is a brick again. Put this brick together with other bricks (a navigation brick, a sidebar brick, a footer brick) and viola: A Super Brick: A page!
I guess those that know HTML recognise the transparancy: After all a brick is nothing more then a DOM-node (a node as the XML language, has nothing to do with a Drupal node). A dom-element, so to say, but then in PHP, instead of in XML/HTML.
