Hexagon

dvessel - April 22, 2008 - 18:43
hexagon.png

Hexagon is a theme engine for Drupal 6 that will provide a standard interface for extensions (plug-ins). The engine will be as slim as possible only providing the hooks needed to intercept and control the call stack on the theming layer.

The goal is a simple one. Allow theme developers to build and share libraries of extensions. Depending on how an extension is implemented, it can be reused for many projects. The idea is similar to modules but focused only on the theming layer and scaled down. Enabling the extension will be as simple as adding another entry into the themes .info file.

Specific functionality can be localized into extensions further separating any complex logic that may exist inside the themes template.php file. If a theme running under Hexagon does not take advantage of any extensions, it will behave like the default PHPTemplate engine. This also means that changing the theme engine from PHPTemplate to Hexagon and back should not cause side effects.

Why not just work through modules? Well, modules are on a separate layer from the theming system and they have limited control of what can happen within a theme. The theme engine on the other hand can work very closely with the active theme.

Here are the planned features and ideas:

  • The extensions will be enabled through the theme's .info file with a new entry of "extend[CONTEXT][] = EXTENSION_NAME". The "CONTEXT" can change it's meaning depending on what the extension is trying to accomplish. For now, it only means the theming hook the extension is attached to or "default" so it can be applied to all hooks.

    The extension can get very specific control of which hooks it applies to if necessary through a settings function. (See below.) Allowing themers to define the hook is there for very generalized extensions that may apply to any themable hook.

  • Each extension is a separate file that may be located in the same folder in hexagon's directory, any base themes or sub-themes directory. Anything enabled in the active theme can override the extensions set before it. The core concepts of overriding will carry over to some degree in this system.

  • Each extension can have a "settings" function that tells hexagon what it is supposed to do. It can define where the extension needs to be applied. For example, an extension named "foo" will have "extend_foo_setings" invoked returning information on how and where it should apply.

  • All the points of extendablity is still being considered and worked out. It currently allows altering of the theme registry and control over the preprocess functions in a more direct manner making it more flexible and easier to work with. The extensions can also have an init function.

Feedback on the approach is welcome. It doesn't look exciting now but it will allow more portable code and interesting tricks. See the example extension provided with the engine.

To enable it, change the engine key within your themes .info file from phptemplate to hexagon and add the entry for the example extension.

engine = hexagon
extend[default][] = example

If the theme is dependent on an existing engine, for example, the theme has theme overrides using the name of the engine, you can add this entry into the .info file.

engine compatibility = phptemplate

The code is alpha quality.

Releases

Development snapshotsDateSizeLinksStatus
6.x-1.x-dev2008-Apr-2839.59 KBDevelopment snapshotDevelopment snapshots are automatically regenerated and their contents can frequently change, so they are not recommended for production use.
 
 

Drupal is a registered trademark of Dries Buytaert.