I'm ripping apart and redoing the smarty theme. When I'm done, I will release my efforts so that anyone out there who wants to use smarty but doesn't want to mess with the guts doesn't have to. But I'd like a little help first.

Currently (at least in the smarty theme), boxes are used for the "sidebar" items such as login, user controls, archives calendar, etc, and also for 'main page' content such as on the user info page and also when viewing full nodes. I would like to change this so that sidebar boxes are a style unto themselves and main content boxes are customizable separate from sidebar boxes. I need to find where the code they share in common is, and where they are called from.

I can do this myself, eventually, but if anyone out there knows off the top of his/her head and can help me I would appreciate saving the time and being able to spend that time developing the new theme instead

Cheers

Amy

Comments

ax’s picture

Currently (at least in the smarty theme), boxes are used for the "sidebar" items such as login, user controls, archives calendar, etc, and also for 'main page' content such as on the user info page and also when viewing full nodes.

this usage of boxes ($theme->box()) is the same in all drupal themes. the relevant pieces of code are

  1. theme_blocks(<region>, $this)
    called from whatever theme to render blocks ("sidebar" items)[1], and
  2. function theme_blocks($region, &$theme) {
      // [...]
      $theme->box($block_data["subject"], $block_data["content"], $region);
      // [...]
    }

    in theme.inc, actually rendering them.

I would like to change this so that sidebar boxes are a style unto themselves and main content boxes are customizable separate from sidebar boxes.

i completely agree with you in that blocks should be styled different than boxes. at the end, they are both from a style and from a functional point of view quite different to boxes, which are actually containers for content for the main, content column (in contrast to blocks being sidebar containers). i'm actually doing this in a theme i did for my site[2]. watching the snippets above you may guess how:

i don't call theme_blocks(<region>, $this), because this renders the blocks as boxes. instead, i

  • put a copy of function theme_blocks($region, &$theme) into my theme as a theme function ($theme->blocks()),
  • added a theme function $theme->block(),
  • and changed my $theme->blocks() to call my $theme->block() (instead of $theme->box()).
  • now, to render the blocks, i don't call theme_blocks(<region>, $this) anymore but my $theme->blocks().

understood? Only local images are allowed.

i think / would suggest that a similar change should be done to the drupal core. comments?

[1] the first parameter specifies the region for blocks to be rendered, ie. theme_blocks("left", $this) renders only left blocks, "right" right blocks, and everything else ("all") all blocks. note that there has been discussion about supporting more that just 2, actually arbitrary regions - see here, here, and here for discussion and here for an implementation.
[2] with the final goal to enable blocks to be en/diabled, collapsed, and reordered by the user straight from the homepage.

amy-1’s picture

I've got your gist, and I'll probably get it completely when I get some sleep and then look at the specific code in question.

I figured it was probably an 'issue' with the core of drupal and I would strongly support such a change. I'm a designer first so this one bugs me particularly. I'm excited about being able to contribute to fixing it, and maybe even helping out with other stuff. Only local images are allowed.

Anonymous’s picture

I've been messing around with drupal to create my own site, and this is one of the things that bugged me.

Drupal should really only create PHP arrays that are then rendered by a user selected template. Like the filter system, this is another part of drupal that's within a hairs breath of being elegant, but just barely misses, and becomes difficult instead Only local images are allowed.

This having been said drupal is still my choice of PHP weblog, I just wish the rough edges would go away Only local images are allowed.

amy-1’s picture

It seems like the best out there, but that doesn't mean it's the best it can be

Of course the thing to do is to start fixing stuff yourself, being that it's an open source project. The great news is it's already to a pretty high level of polish. Only local images are allowed.

moshe weitzman’s picture

Drupal should really only create PHP arrays that are then rendered by a user selected template. Like the filter system, this is another part of drupal that's within a hairs breath of being elegant, but just barely misses, and becomes difficult instead

this seems like how the theme system works today. theme developers can change the default rendering of anything by writing their own render function. See theme_invoke() function in theme.inc file.

so how can we improve the theme system?

4.1RC will give you the best success when playing with themes.

0116’s picture

So what exactly do you have to add to a box in php so that it displays like other boxes?
Perhaps there should be a separate box/block included with drupal- it's hard to figure stuff out when most of the boxes are part of bigger modules.
Say i want to add a box that prints out the date on the front page?
echo $date;
but what about getting it to look uniform with other boxes?

ax’s picture

you may be interested to learn that yesterday dries included into core cvs a patch i had submitted that adds a new function block() to the BaseTheme class and uses this function to display the (sidebar) blocks. this means now you can style (main content) boxes and (sidebar) blocks differently by (in addition to the usual box()) implementing a function block() in your custom theme.

block() has the same parameters as the box()function:

function block($subject, $content, $region = "main")

.