include wgSmarty_theme.php to allow more customization per theme

stephanmaximili... - November 7, 2005 - 12:08
Project:wgSmarty theme engine
Version:HEAD
Component:Code
Category:feature request
Priority:minor
Assigned:Unassigned
Status:needs review
Description

Hi,

I am in the need to improve the wgSmarty-Engine (to theme the menu for example) but the current implementation does not allow it, without modifing the theme-engine-file.

I think a better approach would be to include the php-file, which defines a theme as a wgSmarty-compliant-theme, the file wgSmarty_theme.php. This file could extend the wgSmarty-Engine inside a theme nicer and cleaner than hacking the engine itself.

To include theme-specific PHP-Code just replace the function wgSmarty_init with the following:

function wgSmarty_init($template) {
    require_once(dirname(__FILE__).'/class_wgSmarty.php');

    global $wgSmarty;
    $wgSmarty = new wgSmarty;

    // include wgSmarty_theme.php file, so it can extend the engine :)
    $file = dirname($template->filename) . '/wgSmarty_theme.php';
    if (file_exists($file)) {
        include_once($file);
    }
}

Sorry, I am new to drupal, if there is another approach to solve my problem, disregard this feature-request.

#1

tclineks - November 7, 2005 - 17:20

This code looks functional to me.

The Smarty Theme Engine (http://drupal.org/project/smarty) which I maintain has this functionality already. (the filename is 'smartytemplate.php')

I've also included an easy way to make your functions available to Smarty as to call them with {functionname var1=value1....} as opposed to {php}echo functionname(value1, ...);{/php}

I haven't yet written explanatory documentation but I should have it out soon.

tclineks

#2

stephanmaximili... - November 8, 2005 - 17:52
Title:include wgSmarty_theme.php to allow more customization per theme» thanks

... so I moved my theme back to Smarty (I switched to wgSmarty because of flexiblock)

I added a new Smarty-Plugin which includes a specific flexiblock on demand.

#3

tclineks - November 8, 2005 - 17:55
Title:thanks» include wgSmarty_theme.php to allow more customization per theme

Great, send it over (use contact form if you'd like) and I'll consider including it as a contribution.

 
 

Drupal is a registered trademark of Dries Buytaert.