This is the follow up to Open discussion on Drupal's themeing capabilities and templating engines., and is more technical in nature than the previous article. This article intends to go into depth about the nature of the current system, and what possible improvements could be made in the future.

It will attempt to refer to as much actual code as possible, so much so that I am starting to wonder wether it would not have been faster for me to just write the code and get it done with, however.. I also feel that it is important that contributing designers have a reference point for the nature of these changes, hence this discussion.

I am only indexing the current Drupal 4.4.0 contributed themes, as they are the only ones which would be able to support all the drupal features. Unsupported themes that should be indexed additionally should please be mentioned in the following discussion.

Proof:

Drupal themes currently reimpliment a lot of functionality that could be centralized, and allow for themes to be more easily constructed.

Experiment:

Research all of the currently available themes, and index the features they support which are either inherent in Drupal, or configurable in the theme setting page. Also take note of all the theme_ hooks they override.
Method:

I synched with the current status of the DRUPAL-4.4 contributions cvs branch, and copied all current contrib themes into my current stable testing directory. I was left with the following themes after modifying or removing the incompatible ones : adc, chameleon, goofy, interlaced, marvin_2k, phptemplate, slurpee, sunflower, unconed, xtemplate

GWorks is named xtemplate.theme, and is such incompatible with the default XTemplate theme, and as such was removed. Marvin_2k is the predecessor to the PHPTemplate theme, and uses the same template library , but doesnt perform a conditional include check for the existence of the library, this was added. Since Example is not a complete theme, I have also not included it in this discussion.

I then enabled all of the themes, and went through each of them to verify which features each of them supported, and then used the resulting information to compile a feature matrix.

Default functionality is defined as settings that are configured / required by the drupal core. The theme supports the feature when it either displays, or allows the site owner to display the contents of these fields.

  1. Site name
  2. Site slogan
  3. Primary navigation
  4. User navigation block
  5. Mission
  6. Footer
  7. Sidebars (left, right or both)
  8. Breadcrumb Trails

Additional functionality is defined as any features that the theme has above and beyond these.

Results :

The complete feature matrix hopefully gives us an overview of just exactly what all the current themes can do. Where menu support is noted as partially , the stylesheet provided with the theme was causing the indent on menu items to push halfway across the page when in the admin menus. Not a big fix needed, but it still wasnt working out of the box. PHPTemplate and Marvin_2k are directly related and as such share most of the same supported features.

The great majority of contributed themes do not seem to have their own settings page, and as such do not allow much modification from with Drupal itself without modifying the theme. A great improvement from previous versions is that all the themes test support both sidebars without any hassle. A lot of them , most specifically xtemplate (!) do not support the primary navigation links as defined by the modules, or the primary_links variable in the configuration file.

It is telling to notice that the mostly it is the template engine supporting themes that define settings pages for switching templates, and chameleon for switching stylesheets.

Visual overview

The following Current theme system overview was designed taking into account that there are 4 main components of the drupal theme system.

Internal theme API
When a new module is developed, all of the markup generating functions are (should be?) seperated into their own theme_hook($parameter) functions, and called using the theme("hook",$paramater) function.
Public theme API
When a page is displayed, Drupal attempts to load the specified theme file, which contains functions in the format of themename_hook. Internally in the theme() function, it checks for the existence of a themename_hook() function before defaulting to the module specified theme_ function
Markup / Skeleton layer
The output generated by the themeing system in the form of (hopefully valid) html. In certain themes (phptemplate and xtemplate) the markup and core theme logic are seperated to allow for easier customization by designers and other non-technical folk. The template selection generally takes place in the theme specific settings screen.
Style / Skin layer
Currently only chameleon allows the user to select the template they wish to use with the site, so as to allow varying designs that do not need to modify the markup/skeleton layer

Benefits of the theme system

It is incredibly customizable, to the point of making many things not normally possible, easy (to your average drupal developer). It is quite close to the Drupal core API in implementation, and thus allows module developers a similiar interface to providing markup for their contributions.

Problems with the current approach

High barrier of entry
Not everyone is a developer, and the barrier for entry to normal designers is artificially high. It is considered the norm that most people should probably use xtemplate to design their site, as it allows easy copying and modification of the template (to a point).

Users wishing to customize their site are expected to learn php, the basics of the drupal theme API, and very likely the xtemplate library , where an intelligent and user-friendly set of customizable options could instead be defined.

No consistency across themes
There is a marked lack of consistency in supporting even the most basic Drupal requirement in all themes, and there is also no way for novice users to configure a lot of very common display settings without modifying the template, and this breaking compatibility and causing themselves upgrade problems in the future.
Lack of configuration options / deluge of incompatible configuration options
Some of the most common actions, such as uploading your own logo image, is still not supported from within the interface.Different themes have different settings, and they do not respect each other's settings. Configuring the primary links for example is different on xtemplate and phptemplate, and phptemplate doesn't even support a secondary set of navigation links, much less allows them to be configured. A complete set of requirements to allow for consistent user experience is not in place. Some themes will not even load without modifying the .theme php code , which in turn makes the theme incompatible with future versions.
Technical concerns
When it comes down to it, most themes really are not that complex to begin with, they override only the most basic set of hooks available in drupal (page, node, comment, block and box) , and most of the common ones do not have any additional settings, but the settings that are presented to the user should very likely be available to all themes. Also, because of the structure of the theme system at present, we consider the technology used to define the markup , more important than the markup itself. The user should not neccasarily be confronted by the fact that his site is generated via the xtemplate library, however knowing that he is running the Pushbutton design is pertinent to his needs. Since each theme has it's own set of supported features , even the same template for a different template based theme will likely be markedly different in capabilities. If a template theme developer wanted to enable the templates to take advantage of configurable stylesheets (like chameleon does) , the resulting path (both on the file system, the menu and regarding the basic logical depth of perception) will be between 4 to 6 levels deep.
Unneccesary code duplication
The Phptemplate and Xtemplate themes are not very different in nature, yet the current system leaves us no choice but to maintain completely seperate and subtly incompatible versions of these themes, along with the additional work that supporting additional template engines in their own themes,three levels down in the directory tree, five levels down in the system menu, and many levels down in the logical system view.

Supporting additional templating engines with the current system , requires wholesale duplication of many hundred lines of code, specifically template selection and basic template configuration code.

Proposed solution
Centralized configuration
Define a set of configuration settings that should be configurable from within the administration system, that handles some of the more basic display configuration requirements. Exampled of this would be enabling the user to upload his own logo to use instead of the default, and optionally toggle the display of avatars or the site name in the header. Users who do not have a graphical logo, and lack the abilities to create one themeselves, are currently forced to modify their chosen theme , simply to be able to display the name of their site.
Required features for any contributed theme/template
Maintain a checklist of required supported features for any template or theme that applies to be distributed on Drupal.org , that is designed to define a mimimum level of configurability across all themes or templates, to allow new users the ability to modify their site without needing to modify anything other than the settings in the presentation menu. This might not seem important to the average developer, but being asked to open an xtemplate file to change something menial, can be incredibly daunting to a very novice computer user.
Implement a template layer
This template layer is intended to allow developers to modify their site in any supported templating engine, while also not requiring the core Drupal project to designate a primary template library for use with the system. This template library is a simple abstraction layer that allows developers to target the library that suits their project. This does away with layer of complexity in the file system and administration trees, and is more userfriendly in that it gives the user a more consistent view of the available options. This should allow us to allow configuration of drupal .theme's and template files , from within the same interface.
Require style/skin layer support
Since templates and themes are now on the same level, it doesn't add too much complexity by adding stylesheet switching as a requirement to all themes/templates. This would go a long way to helping the user configure and customize his site without needing to break compatibility with the theme or template in future versions. additionally ..
Configurable overriding CSS
Additionally allow the user to specify additional style rules for each template, directly in the administration interface. This would allow for small modifications ,such as padding the space around the logo that has just been uploaded, without requiring ftp access to modify files which may or may not be accessible to the user. These rules should be saved in a custom.css file in the template directory
Easy copying of templates and styles
Provided the markup is not implemented using a standard drupal .theme module, it should allow direct copying of templates and stylesheets for configuration purposes. So the user can copy and modify the pushbutton template without having to open a php file and executing a global search replace, and then hope it worked. Additionally this should allow for easy installation / distribution of Drupal templates / styles. I intend to teach the install api to maintain the themes and styles available along with contributed modules.
Base theme to be supported across all template engines
To fully allow the utmost configurability and customizability of Drupal to as wide an audience as possible, we should maintain a 'default theme' , which represents a 1:1 ratio to the required features for that version of Drupal. This markup will have to be generated exactly by any templating engine hoping to be distributed on drupal.org, as a functional unit test that ensures a minimum level of compatibility with the defined standards. Because the markup should be identical across different implementations of the theme, the css should be perfectly cross-compatible between said versions. As the bulk of the customization process will hopefully be happening in css applied to this default theme, it creates a 'known good' starting point for designers who have started to require modifications to the actual markup. Because this theme is implemented in every templating engine, the designer will only be required to choose which engine he is most comfortable with, and need not be required to learn any (or much, depending on the situation) php to accomplish his task
Document the stylesheet capabilities of the default theme
Extensively document the tags, and possible designs that can be achieved by applying css to the default theme. Because this theme is being bred to be the starting point for most designers, the existing stylesheet framework will hopefully deliver a lot of value to them , in that they will likely already have memorized the class and id names of all the main elements. A forum dedicated to little snippets of CSS for customization would also help a lot of users apply their own 'fingerprint' on their sites. Moveable type already has such a framework in place, and along with decent documentation and support channels, the stylesheet capabilities will likely be able to satisfy most of the Drupal customization requirements from your (a bit more experienced) average user.
Maintain compatibility with Drupal theme API
Current themes should not be completely broken by the new advancements, but should still work with the system, as the theme api is still probably the most flexible method of modifying the generated markup , and any system that extensively modifies the output of Drupal beyond the capabilities of the template system, will still need to be able to define theme_ overriding functions. An average user should however not be required to develop extensions to the theme API unless there is a really special requirement that could not be solved from within a templating framework .. which means.
Optional additional logic to be loaded for templates
Since templates can in many cases need direct access to the drupal theme api, allow the template to contain an additional php file that will be included if found. Any additional code will be executed upon loading up the template, and the file can contain, for instance, overriding theme_ functions that would still be honored by the theme system
Move/rename theme menus
The admin/system split which puts your average theme configuration page four levels deep in the tree requires too much navigation to reach, and even then is still too deep down into the tree to deliver any more meaningfull branches (configuration settings per stylesheet for instance). The configuration should be moved to admin/presentation , which allows you to select the active template, and there should be a menu entry for each template, where you are able to override some settings specifically for that template ( a different logo might be needed for instance) aswell as selecting the stylesheet for those available for that template. Adrian Simmonz suggested that we name the template/markup layer the 'skeleton' layer, as it provides the framework for the html that is to be generated, and furthermore name the stylesheet layer the 'skin' layer. This would be accesible to a great many novice users who will be able to relate to the functionality offered by the system.
Impliment new menu editor
Leverage the new menu editing functionality in HEAD to allow a minimum of 2 sets of navigation links to be configurable from within the user interface, and also allow the template users to easily extend the sets of links in as many ways as possible
Attempt to provide painless template extension functionality in most cases
This is likely applicable for just about every templating engine but xtemplate, in phptemplate for instance, you should be able to create a user_list.tpl.php template file within your template directory, that will be loaded and used to override the theme_user_list() function. This will require some presentational logic to be used within the template files, which xtemplate does not allow, so you will always need to create additional templatename_hook() functions to drive xtemplate. The benefit of this additional override functionality is to hopefully allow as much of it to take place without requiring modification of the default template. Once again , I can hear many people puzzle as to why I don't want people unneccesarily editing the templates. It comes down to a simple support question. If you change xtemplate default or any other theme extensively, keeping track of your changes can be a very taxing prospect. By trying to keep the only really required template free from mods, it will allow for a clean upgrade cycle almost every time. see. method. madness.
Visual overview of proposed templating system

The following graph illustrates the basic logical structure of my proposed template api addition to the method Drupal themeing system. While at first glance there might appear to be more complexity than current theme system overview, it should be noted that the complexity is because of an entire 'layer' of the previous system being integrated into core , to simplify the interface that the user experiences. The user should now be able to simply think of the template being used, and not be worried about the .theme file, until such a point as the user needs functionality that can not be offered from within a templating framework.

The previous phptemplate/xtemplate themes have been rebuilt into 'template engine glue libraries' , by seperating the logic actually used for generating the output, from the logic that was used to configure the system. These functions have been centralized to allow all templates to be configured centrally.

The style layer has been extended to cover all contributed themes and templates, so as to allow for the maximum amount of configurability. The style layer uses most of the same code that the template switching does, except applied to switching available stylesheets within the selected template.

The configuration layer has been added to the theme api internally as to allow for extensive and consistant configuration options. Because these options are now centrally configurable, you are able to override them intelligently , like for instance be able to specify a custom stylesheet for every user, or tie the template/stylesheet used into the path currently being displayed. This would allow sites to create very customizable front pages using push/pull hybrid templating with phptemplate or the like. They would simply be able to create a template to be used for front page

Final words

Since I have now probably confused a bunch of people again, and I feel there is enough information here for the general populous to digest now, I will take my leave and continue with the spec tomorrow. But i just have the following to say :

YES current drupal themes will be mostly completely supported. They will masquerade as a template type called '.theme'. The theme.engine glue library will simply load the theme on template inilitialization, and since theme functions still take presedence over template functions, there should be no change in the rendered code, unless you specifically require the theme to be in themes/ or some other specific little bug. Settings might also be unavailable until a consistent way to integrate them is found

YES very little modification of the core system will actually be required, the bulk of the changes involve changing the theme system to a) check for a valid template based solution if no overridden theme_ function was available, and b) removing the theme configuration / loading system and replacing it with a template based solution that loads the right glue library, which may or not be loading a real.theme file. (if it sounds complex, it isnt. really it isnt)

YES you will hopefully soon be able to install templates and styles from the Drupal website using the install api. And css zen garden is actually a very apt example of what is capable of the proposed solution

NO no, i don't think this is adding too much complexity to the default system, I believe that from a useability perspective, the proposed changes have a very real benefit for novice users. The new system centralizes a lot of things that are currently not well supported, or do not have the neccesary documentation written.I believe that one of the major methods of allowing a much wider audience to find Drupal is to stop making all the sites look like xtemplate/marvin hacks (which they are) , and to grow the designer community interested in doing Drupal projects.

YES I still expect the first reaction of Dries/Unconed to be related to capitalization or spelling / grammer. At 4am on a tuesday , those facets of my brain tend to fizzle out and die.

YES I do sleep far too little , and I really should be getting into bed soon

Comments

drumm’s picture

I'm going to read this on the train. Here are my printable versions:

PDF (6 pages, generated with FireFox and ps2pdf)
HTML (if you want to make the font smaller for less pages)

Make sure you grab the three linked charts as well.

jweiss’s picture

First off, let me admit to two things.

1) I'm new to drupal anyway

2) I'm one of the confused people adrian mentioned.

Anyway, as someone who hasn't gotten the hang of modifying (let alone building) themes, I'm wondering... couldn't we just build some sort of extension for dreamweaver so the goofballs like me can point and click? And for the parents out there.. MT has one, why can't we?? ;)

adrian’s picture

Take a look at this valid phptal based template. I intend to support the library with the new templating api, alongside a few others that would allow for a wide variety of choices

  Sanity is a sandbox in the playground of my mind.
     I'm going to go play on the swings now.
capmex’s picture

I have checked the link and it doesn't validate, there are some errors in some attributes tal:content, tal:repeat, etc. that are not part of the doctype.

Webmaster Resources for Business Websites

judah’s picture

What I've wanted to do and what I want to do is create my site layout in Dreamweaver, Fireworks or Photoshop. What I want to do is make my layout and then put tokens or placeholders where the content will go.

My First Solution:
I started developing a plug in for Macromedia Fireworks that will write out a drupal compatible theme when exported from Fireworks. This has been incredibly hard to do and I've been working on building a whole new behaviors system to support all the code drupal integrates into the themes. But it has taken a long time and it is only half way done.

My Second (simpler) Proposal:
I suggest, instead of writing out to the browser as we go along or to one output variable, each module or function write to it's own variable or a global array. Then we have a table in our drupal datbase called "designtemplates" that contains various xhtml pages layouts. These pages have drupal specific markup describing to drupal where the modules content goes. Drupal then merges the xhtml designtemplate with the drupal contents and sends it to the browser or (another function hook and then the browser).

So we as a designer create our website exactly as we want to in Dreamweaver, Photoshop or whatever and anywhere we want drupal content we put a markup tag or a token such as "<DrupalBlock>" or "<myDrupalBlock style1='myClass' style2='myClass2'>". You can pass the style tags you want to apply along with the tag and drupal will apply the tags the drupal content. The designer will never have to leave the graphics program or rarely.

Please read the Process:
- User Requests page
- Drupal gets request and generates all the dynamic content and puts that into variables, arrays or objects.
- Drupal gets generic xhtml page (made by designer and uploaded to the pagetemplates table). This page has drupal specific markup tags of where drupal content should go.
- Drupal performs a search and replace function on the template page. This function does two things.
- One it finds the tag and replaces the tag with the contents of the variable or array that drupal created.
- And two, it adds any style attributes defined in the drupal markup tag to the drupal generated html output (this adds any style defined by the graphic designer to the html elements).
- Finally it sends the output to the browser.

Here is an example:
<html>
_<head>
__<drupalhead>
_</head>
_<body>
__<div>
___<drupalblock style1="darkGrayClass" style2="title" />
__</div>
__<div>
___<drupalcontent />
__</div>
_</body>
</html>

The output would be:
<html>
_<head>
__<title>Preview comment | drupal.org</title>
_</head>
_<body>
__<div>
___<table style1="darkGrayClass">
____<tr>
_____<td>
______<h2 style2="title"> Active forum topics:</h2>
_____</td>
____</tr>
____<tr>
_____<td>Block contents go here
_____</td>
____</tr>
___</table>
__</div>
__<div>
___<Drupal content html would go here. You get the point./>
__</div>
_</body>
</html>

Notes:
- You could have the modules disclose to the user or administrator the style tags that it generates in the module help text or wherever. Takes two seconds to add.
- You could also have drupal markup tag to apply to specific blocks by name. Include a name attribute that if the markup name attribute , "name='navigation'" for example, matches the side block name as itis looping through all the blocks, then the markup tag styles would apply only to that block.

If you can do this then I'd be happy. I could use my existing tools I already know.

adrian’s picture

of having a diagnostic template that automatically prints out all the variables passed to it.

It would essentially give you the information you need to override just about anything in a template only form (provided you arent using xtemplate)

re: rest of your template comment. I do very highly recommend you check out the phptal templating engine. All tal templates are 100% valid xml, and the templating instructions are embedded withing the tal: namespace directly in the html. It takes a couple of minutes for a programmer to embed the logic into the static html document generated by the designer, and this make that the static document _IS_ the template.l It modifies perfectly from within dreamweaver

You can for instance use the tal:replace="structure document/block" tag in any html to replace it with the markup (structure) defined in the document->block object. The entire template gets fed that way.

regarding wanting to get the objects for all the drupal function calls, that would be pretty easily implemented in a glue api.

  Sanity is a sandbox in the playground of my mind.
     I'm going to go play on the swings now.
judah’s picture

I like it. I can work with something like this. My only concern is that you make sure to keep it backwards compatible. If I were you I wouldn't even try to reinterprit the old system.

I would do a:

if (AdminWantsOldLegacySystem==true) then
// all the old theme code
else
// do your new fandangled thing
end if

Just so you can always fall back on the old system for emergencies.
Good job on the layouts man...

Judah

moshe weitzman’s picture

the latest thinking in web design (last few years) is quite different from what you propose. you should really work on learning CSS. It is rare that you have to edit HTML at all. Editing the stylesheet is usually all thats needed.

judah’s picture

I know CSS but I don't particularly like designing with it. So I really think it is a matter of preference. I like to design in Photoshop, break it out into liquid tables and then put my content where I want in Dreamweaver. I like what CSS offers and I use it some but using it is like handcoding which I don't like if I think it should be accomplished by a visual program. And for me I only use CSS for setting font styles, headerstyles, links and blocks but not the page layout.

There is a whole huge issue here that you opened up. An issue that I'm trying to resolve with a Fireworks/Photoshop program/plug-in that will merge the two (more about that another time). On one hand you have a very powerful visual design program like Photoshop. Then you have CSS which is basically the internal layout code for what you are designing in Photoshop but with some more options. Except in CSS you don't have to create the layout by hand describing where objects are and what they look like. If Photoshop could integrate CSS into it's layout I wouldn't be so adamant about having an template based system.

But with what Adrian is describing you can have both. Also, from what I read, PHPTAL wont touch any tags or attributes except it's own.

Robert Castelo’s picture

You might be interested in giving Adobe GoLive CS a try. It integrates very smoothly with Photoshop, so you have the graphics power of one and the CSS/XHTML power of the other in a tight workflow.

-- Pushbutton Test Experience -->>

------------------------------------------
Drupal Specialists: Consulting, Development & Training

Robert Castelo, CTO
Code Positive
London, United Kingdom
----

adrian’s picture

The reasoning behind having a single default template across all template engines, is because 99.9% of the time, there shouldn't be any need to edit the template.. but in those cases where there is the need, the designer has the choice of working with the templating engine he feels most comfortable/suits his needs the best.

I am not trying to say that all template engines are created equal either, but we shouldn't have to penalize people because we don't use their engines.

  Sanity is a sandbox in the playground of my mind.
     I'm going to go play on the swings now.
TiViTi’s picture

i like judah's example... somenone have to do this...

TDobes’s picture

Under Move/rename theme menus, you mention The configuration should be moved to admin/presentation , which allows you to select the active template, and there should be a menu entry for each template, where you are able to override some settings specifically for that template ( a different logo might be needed for instance) aswell as selecting the stylesheet for those available for that template.

While I agree with this to a certain extent, I feel that this alone is insufficient. Selection of stylesheets/templates/full-blown themes should all occur within the same screen. Selecting a stylesheet from an admin menu for xtemplate makes sense if you're an administrator, but what if you're just a user attempting to customize how the site looks? As a user, you have no idea what "xtemplate" is; you just want to make the site look different. Therefore marvin.theme, pushbutton in xtemplate, and the default xtemplate style all are just different appearances for the site.

In order to give users of my site these options, I have to run three customized copies of the xtemplate theme to allow my users to choose which template they'd like to use. I know that most site admins want only ONE look for their site, but the ability to switch themes is one of several features I use to "entice" my users to sign up for a user account. (and thus avoid the ever-present "Anonymous" comments)

Other than that, I think your goals for the theme system are excellent. I'd really like to see more themes available for Drupal, and your efforts may very well help with this goal.

adrian’s picture

xtemplate and the like will never be a selectable option

you would have pushbutton, bluemarine (the default xtemplate's real name) , marvin_2k and chameleon at the top level. For each of these template files (which are transparently designed in different engines. or the same. or who cares , most people dont need to modify the template) there can be several different styles.

Full blown themes will also be transparently supported as a .theme template type.

Why not have all this in the same screen ? well .. space really. Each template and style could concievably need customization options / overrideing logo's and the like.

So the designer can create one template, and allow users to switch styles or use the path based template/style switching i intend to implement. or build a module that switches to certain templates on certain days. hell. whatever.

The idea is .. that you would be doing away with the entire technical level in the main interface (you would NEVER have to say which template engine you want to use), and there would be 2 main variables to switch between templates and styles , and by default all the templates will support enough of the same functionality to make it practical to manage

  Sanity is a sandbox in the playground of my mind.
     I'm going to go play on the swings now.
TDobes’s picture

Thank you for explaining this to me. This sounds like an excellent plan, and I look forward seeing it. Just to be sure: Users will now have two options, one for "template" (including xtemplates, phptemplates, and old-fashioned .theme files) and one for "style" (which would select different CSS files as chameleon.theme does currently). Does that sound right?

On a totally unrelated topic, I fixed the problem with the "User navigation block" in the adc, interlaced, sunflower, and unconed themes.

Robert Castelo’s picture

..eerh, why do we need 2 selections (template and CSS stylesheet)?

A CSS stylesheet can make really extensive changes to the look of a site, almost as much as a template, why differentiate between the two in the admin interface?

Wouldn't it make things simpler to group templates and stylesheets in the same selection? That way the admin just picks the look they want without having to think about the technology.

-- Pushbutton Test Experience -->>

------------------------------------------
Drupal Specialists: Consulting, Development & Training

Robert Castelo, CTO
Code Positive
London, United Kingdom
----

adrian’s picture

stylesheets will always make changes to the look of the site. templates might make changes to the markup of the site.

Because certain templates could have additional options that need to be set.

Because 2 selections , with the default being used in almost all the cases, allows for the greatest extendibility. You might for instance want to allow users to select the style, but not the template.

I did only want to have one selection at first, but then I realized how difficult to navigate the options become, and how confusing a screen with 70 little radiobuttons and screenshots is.

  Sanity is a sandbox in the playground of my mind.
     I'm going to go play on the swings now.
Robert Castelo’s picture

I'm not sure if it's a good idea for administrators to upload their logos through the Administration pages.

Trying to shoehorn one logo file into different template designs might not look good....

http://garage.docsearls.com/?q=node/view/9

A logo with a transparent background might blend in well in all templates if it was a PNG file:

http://www.mulliganspub.it
(note the logo is a transparent PNG file)

But Internet Explorer Windows has poor PNG support.

If a GIF is used instead it will have very ugly pixilation around the edges of solid areas if the background colour is different from the colour that was made transparent.

For best results, Admins should be provided with a SDK (Standard Development Kit) for each template, containing all the PNG graphics files they need to seamlessly add a logo to the their site and make other customisations. They can then upload the customised files into the specific template directory.

This also allows admins to customise rollover effects for logos

------------------------------------------
Drupal Specialists: Consulting, Development & Training

Robert Castelo, CTO
Code Positive
London, United Kingdom
----

adrian’s picture

everytime i curse microsoft ie on #drupal because of their lack of png support. it's because I realize just how difficult they are making everybody's lives.

And providing image packs with layered source images should not be a requirement for contributing to the drupal template/style pool, but that would make a contributed template be more popular and visible.

It is going to be impossible to make a system whereby the user is saved from their own bad taste, but that isn't a reason to make it hard for the user to experiment. The issue here isn't not allowing the user to upload their new logo. It is trying to shield the user from having to modify a file, or crack open an ftp client .. just because they want to have a picture with their name on it.

  Sanity is a sandbox in the playground of my mind.
     I'm going to go play on the swings now.
Robert Castelo’s picture

There are two methods we could use to handle logos, the Graphic method (changes are made to the template's logo files), and the Administrative method (logo is a variable holding the link to logo file)

Lets examine the steps neccessary for each method:

  1. Create graphics

    This step is neccessary for both methods.
  2. Upload graphics

    Neccessary for both, but requires different action.

    Graphic method - upload graphics to template directory, overwrite existing files.

    Administrative method - Admin needs to think about where to upload graphics.
  3. Link to Graphics

    Graphic method - doesn't need this step.

    Administrative method - Admin needs to work out the filepath to where they uploaded the graphics, needs to go to Administration pages to input file path.

The Graphic method has the advantage that it requires less steps, and the Administrator doesn't need to think about file paths.

Also the Graphic method frees designers to setup logos with CSS or Javascript rollovers, which would be difficult to do with the Administrative method.

The Administrative method has the advantage that logo files can be placed outside of the Drupal instalation, and after a Drupal upgrade will not need to be uploaded again.

To my mind the Graphic method is easier for designers and administrators

------------------------------------------
Drupal Specialists: Consulting, Development & Training

Robert Castelo, CTO
Code Positive
London, United Kingdom
----

Jose Reyero’s picture

The main problem I find when customizing existing themes is that we have the basic theme -theme.inc-, then the actual theme -xtemplate-, and then no place to override anymore the theme functions. Thus, the only solution if you want to customize your theme at the code level is to patch the current theme functions.

Also, while the site admin can chose between different xtemplate 'subthemes', it is not an option for the user. But I think that when you go for template based themes for your site, then what you usually want is to have several themes -selectable by the user- based on different templates.

So, what I would like to have -whishlist- about themes:
- Core support for template/php based themes. I think one templating sistem is enough to be supported at this level, and I would go for xtemplate. Anyway, other templating engines can be supported at a higher level.
- xtemplate 'subthemes' reimplemented as themes themselves

Then the new pluggable themes would be either template based or pure php based
- Template based themes will require only the template file and the css, but optionally some php which overrides xtemplate theme functions.
- Pure PHP themes, won't use xtemplate, but will allow other template engines to be implemented.

The pseudo code for theme.inc would be something like

If (current_theme is template based) {
include xtemplate_theme.inc
} else {
include standard_theme.inc
}

adrian’s picture

You describe what I am designing, although my method is completely template engine agnostic. I suppose the post is quite long, but everything is in there, and more.

i strongly feel that a) xtemplate should be supported , for legacy reasons , and b) xtemplate is probably the least designer friendly of the template engines.

The entire reason Drupal doesn't have a cohesive templating system in place, is the fact that none of the developers feel comfortable mandating any template engine over another, and I completely agree with them. XTemplate is only the 'de facto standard' because it ships with Drupal. There is no mandate that xtemplate is the Drupal template engine.

The aim of this system is to abstract the templating engine from the themeing engine , to provide completely transparent support for any template library. Xtemplate will be supported, yes. But I intend to support smarty , phptal and pure php templates too. All of these templates will be seen on the same level as themes are now. And the average user will never be confronted with the templating engine used to display them.

  Sanity is a sandbox in the playground of my mind.
     I'm going to go play on the swings now.
judah’s picture

just do it. I think that once it is up and running you can go back and tweak it. I've read through the posts and I see what you are doing and I think it's solid enough to do it and tweak it later if necessary. Most of the questions here will be answered or addressed once it is implemented. I think you have the best handle on this but if you need someone to bounce ideas off of I'll be available (drumbeatinsight.com). I've done a lot of work in this area.

Chris Johnson’s picture

In addition to being template-engine agnostic, will this API allow me to have a theme that does not even use a template engine? I don't need the large layer of extra cruft adding to my server load when all I want to output is some very simple XHTML mark-up with a light-weight CSS2 style sheet, or maybe even WML or something even smaller to a PDA, cell phone or handheld.

Learning the script to control a template engine is on the same order of difficulty as learning some basic PHP to control XHTML output.

    For discussion as to why templates are redundant in PHP and some other template possibilities, see:
  1. http://www.phppatterns.com/index.php/article/articleview/4/1/1/
  2. ">http://wonko.com/content.php?id=213
  3. http://phpsavant.com/index.php?page=WhySavant
  4. slashdot.org
adrian’s picture

PHPTemplate(which I am maintainer of) is already written with this in mind. Pure php 'templates' are one of the template engines I will support. I also already have a mobile template for the phptemplate theme, and wml wouldn't be _that_ hard to implement.

You will be able to either use the generic php template functionality , or interface directly with the theme system, or use whichever template engine you feel comfortable with.

  Sanity is a sandbox in the playground of my mind.
     I'm going to go play on the swings now.
Chris Johnson’s picture

Yes, I can do that today. I just wanted to make sure I could do that after Drupal was completely modified in the direction you are suggesting.

What you are doing sounds great for a lot of applications, and it's really great that you can put so much work into Drupal. If it doesn't cut off the simple avenues of doing things, all the better.

Thanks for taking the time to respond to my questions, Adrian. I appreciate it.

adrian’s picture

Today is my last day at obsidian systems, so I will finally get the time to turn Drupal into the cutting edge CMS that it deserves to be.

  Sanity is a sandbox in the playground of my mind.
     I'm going to go play on the swings now.
adrian’s picture

I definately would love to see someone make a XSLT template library aswell ... it should be possible with what I have in mind.

  Sanity is a sandbox in the playground of my mind.
     I'm going to go play on the swings now.
devinhedge’s picture

Ok. I don't want to start a flame war... so think of this as a differing opinion or a different spin on the above arguements AGAINST a template engine.

I'm a big fan of object oriented programming. Like most tech stuff, it has it's place and shouldn't be used absolutely everywhere just because it will work everywhere. Second, I'm a MAJOR big fan of design patterns and well abstracted and scoped architectures. I've following PHP Patterns for a while. I particularly love the Model-View-Control pattern in Java, C++ and PHP. It just makes sense: one model of an object, multiple views of the instantiated model, and a controller to determine which view is used. If you think about it, this is a perfect fit for content management systems as you generally need multiple views of the same information (e.g. small blocks, wide blocks, summary blocks, headline lists, etc.).

So it only makes sense that a proponent of the model-view-controller design pattern is going to say that the use of a template engine is redundant. Afterall, the view classes are doing the same basic job as template engine.

Where the arguement falls apart is when you have multiple layers of objects that represent a web page. For instance, my site has a generic "view". Embedded in my site is a page that also has a more specific view, however that view consists of one to many "other" views of specific instances of multiple objects. In this case you have a controller-view-model=>controller-view-model=>controller-view-model, etc. design. It tends to get recursive; however, it does NOT become redundant. The Site collection of classes call the section collection of classes who in turn call the page collection of classes who in turn call the column collection of classes, who in turn call thier respective content modules for some content to return all the way back up the chain of responsibiliy. A template engine is called by each "view" class in order to allow polymorphism WITHOUT having to rewrite the view class. The template, and thus the engine used to fill in the template, becomes the mechanism for polymophism. The template contains the definition of the view for the view class.

Make sense?

Too confusing?

Let me know.

Cheers,

Devin.

zaur1945’s picture

I have installed new theme here http://www.localareaflorist.com
do you like it?

pyromanfo’s picture

I have checked out the latest CVS and I was wondering what the status of this new templating system is. I'm going to be moving http://www.gamerswithjobs.com/ from our heavily modified PostNuke installation to a Drupal based solution. This new theme API sounds like exactly what I need to get the GWJ template done and I was wondering how far along it was and if there was a place I could check on the status or possibly pitch in.

devinhedge’s picture

Hi All,

I knew I had seen this thread earlier but had problems finding again. I have posted some suggestions and wanted to get some feedback about the possibility of implementing them. I have some php code already working, but would need help with the integration. Specifically, I would need help developing the Administration pages.

Take a look at my post and let me know what you think.

 

Cheers,

 

Devin.