I read the comparision discussion between Drupal and Mambo. In several messages it was outlined that Drupal can place blocks only in right and left and not flexible to put them on anywhere where one want. It will be great if this can be changed in upcoming versions.

I am no pro at PHP, so don't know how much time this task will take, but I think it is very important.

parag

Comments

nedjo’s picture

This issue was apparently partially addressed in issue http://drupal.org/node/19694.

nedjo’s picture

Title: Block Placement » Enable multiple block regions (not just "left" and "right" sidebars)
FileSize
8.17 KB

This much-requested functionality - to have the ability to place blocks in more than the two predefined regions - was partially addressed in issue http://drupal.org/node/19694.. But "blocks" are still limited to the "left" and "right" sidebars (hard-coded in block.module).

This patch is a first step designed to enable multiple (eventually, admin-definable) regions for blocks. I've moved the existing "left" and "right" block regions to a 'region' table (with ids of 0 and 1, as currently used in themes). Then all references to the regions are drawn dynamically from the table. This way, if further records are added, they will appear in the list of available regions for block placement.

Doing this actually reduces some duplicated code, since it's no longer necessary to repeat code blocks for each of "left" and "right".

As it stands, the patch doesn't add any new functionality--but I don't think it breaks anything either. New functionality would need (a) new regions defined, and (b) changes to themes. A simple first step might be, e.g., to add a "footer" region and then add a call in the footer generation to append any blocks assigned to the footer region there.

I'm setting this to patch, but I'm aware that it needs some discussion and refining before it'll be ready to apply.

nedjo’s picture

FileSize
5.65 KB

Here's a screenshot showing the block admin page, with drop-downs for region placement (the options are dynamically generated based on defined regions).

adrian’s picture

The biggest problem with this is that you can have multiple themes, and each of these themes can have different regions available.

Also, the method of defining which regions are available needs to be standardised. Some of the work that me and Vlado are working on for the install system would go towards solving that problem (ie: meta information for modules, themes and styles).

This has been discussed to death, but the general consensus has been that we _want_ to do this, but we need to solve a few other problems properly first, the most pertinent being the interface issue. Chris (factoryjoe) recently did a whole mess of workflows for something related to this.

syscrusher’s picture

The first paragraph of adrian's post is a point that occurred to me also, as I read this thread.

One suggestion would be to separate the definition and configuration of blocks, on one hand, from the placement of those blocks, on the other hand.

In other words, Drupal core provides a mechanism defining what blocks exist, which of these are on by default or off by default and user-selectable vs. which are forced on for all users, and the configuration (if applicable) of specialized blocks defined by particular modules.

Each theme provides a standard hook function that returns an array of region names and help/description text, e.g., array('left'=>t('This vertical region is left of the main content area'), 'right'=>t('This vertical region is right of the main content area'), 'footer'=>t('The footer is below the left, right, and main content areas of the page')).

The theme part of Drupal core (i.e., theme.module itself, not the individual themes) provides a standard UI that is displayed within config of *each theme* (but is one physical code base within theme.module) that allows the administrator to map blocks defined by Drupal core into regions defined by the theme, and storing that mapping as an theme-to-block_ID-to-region_ID (with weight) table in the database. From there, the actual page rendering is similar to what's being done now, but there is more of it.

I guess what I'm trying to say is that the key to solving this problem is breaking it along its degrees of orthogonality, and there are three -- two in Drupal core and one in the individual theme.

Scott

Dries’s picture

Scott, is right. The theme should export its available regions. Then the administrator's task is to assign blocks to regions (not to setup regions). A theme could have configurable regions, but that internal to the theme.

To me, the real challenge is the UI and the interaction design. Configuring blocks could easily become a real pain (while most themes continue to use 'left' and 'right'.)

Of course, we can implement all the functionality, default everything to 'left' and 'right', and worry about the UI later. This should be fairly straightforward to implement and nedjo's patch looks like a first step in the right direction.

nedjo’s picture

I agree with the suggested approach of themes registering their regions. I'd see this happening when a particular theme is activiated (or upgraded). Regions would be an array of names (e.g., 'left', 'right', 'footer'). New records would be created in the region table only for region names not previously registered.

Some areas I'm not clear on, or that need further work:

  • Table naming
    Should a new table be 'region' or 'regions' (I've used 'region')? I don't see a convention among existing table names, some of which are singular and others plural.
  • Default values
    I've kept the existing '0' and '1' ids for regions (left and right, respectively), for backward compatibility. But this means we can't use autoincrement for the region id (rid), since autoincrements seem to begin with 1. Likely we should change to autogenerated ids.
  • Initial records
    Using the INSERT INTO statements as I've done for the initial region entries is probably counterproductive, since sooner or later they'll have to be dynamically generated. I was hoping this could be a preliminary patch, with the main work coming later, but likely we need to solve region registration by themes before this patch is applied. I don't have a good idea of how region registration by themes would be implemented (a hook on theme activation?), and invite suggestions or implementations.
  • Theme system changes
    Besides region registration, the other change I'm seeing that would be needed in the theme system is loading blocks by region name, rather than region id. This is because the ids currently used ('0' and '1') in theory might be diffferent on a particular install.
syscrusher’s picture

Instead of having themes "register" their regions, why not just add a theme API hook called them_regions() that returns an associative array of $region_name=>t($region_helptext)? This would be in keeping with other similar API functions, such as those that return what permissions apply to a module or what node types are defined by a module. Most themes are going to define only a small number of regions (two being the typical case now, but I could see five or six in a complex theme), so returning a constant array will be faster than querying SQL to obtain an array of rows.

There could be (optionally, at the discretion of whoever builds this thing) another API hook like theme_region_properties($region_name) that returns an associative array with detailed info for a given region, such as extended help text with recommended usage instructions for the region.

Scott

syscrusher’s picture

s/them_regions/theme_regions/g

adrian’s picture

Because. The most common 'theme' is a phptemplate theme.

And there needs to be a generic method for specifying the regions available, in a non hook_function format..

Themes get their names from the directory in which they are contained.. when copying the theme to another directory, there must be _no_ modifications necessary to allow normal usage. This is one of the tenets of the new template system I designed.

You would need a standard way to define meta-information for themes, that does not need to be modified when copied to a new directory. We are working on this in the install system work, as you need a way external of Drupal to define the module dependencies and some other things.

My approach would be to add a theme.dsc text file to the directory, which would allow you to specify meta-information. For instance :
----
regions: left, right, footer, center, mountie
author: Johnny McAngstyPants
----

syscrusher’s picture

Adrian wrote:

Themes get their names from the directory in which they are contained.. when copying the theme to another directory, there must be _no_ modifications necessary to allow normal usage. This is one of the tenets of the new template system I designed.

A very good point. But region names don't have to be unique across different themes, so my hook function wouldn't have to be modified. The suggestion I made for the mapping metadata was three factors: theme ID or name, region ID or name, and block ID (plus one non-key weight value to order the blocks within a region, but this is not relevant here).

I'm not familiar enough with PHP template to be able to respond to your comments on that one, so if you say it's not feasible to work with my schema, then I'll take your word for it. :-)

Scott

syscrusher’s picture

Oh, wait.....I see now what you mean! It's not the output of the function that is the problem, but the *name* of the function.

Never mind. I concede your point.

Scott

Jaza’s picture

I'm probably jumping ahead a bit here... but something that this patch will have to eventually account for, is how to allow regions to be defined as inline. Allowing a theme to define a region's position as being anywhere on the edge of the page (i.e. top, left, right, bottom, corners, etc) is relatively easy. But what about having a region that's in the middle of a node's body, or somewhere else that's not the edge of the page?

What I'm thinking of, is eventually allowing the custom region system to integrate with the CCK. Like I said, I admit that I'm jumping ahead into the future - the CCK still has a long way to go before it's ready. But ultimately, it would be cool if a theme could define a region as being after, say, the "rating" field in nodes of type "movie review". This would make the region (and the blocks in it) truly inline and in context with the actual content of the node.

This would be a huge step forward compared to the current block system, which doesn't allow you to mix the presentation of blocks and nodes at all. In Drupal ATM, blocks and "the rest of the page" are totally separate, and really you have no choice but to display them as such. The result of this is that information in blocks that really should be displayed as part of a node, gets literally "pushed to the side", and always seems secondary to the actual content. Often the block has content that is just as important as the content of the node itself.

Another option (of less merit, IMO - because of the extra maintenance work, and lack of enforced consistency) would be to have a region filter. You could then choose where to place an inline region on a per-node basis, by entering text such as [region:2] (example based on image_filter syntax) into the node body.

Anyway, just thought I'd throw that idea into the open. I don't expect it will be implemented any time soon, but it's something to think about.

Jeremy

Stefan Nagtegaal’s picture

FileSize
1.29 KB

Imo the 'regions' are more than you guys name here.. FOr example I attached 2 screens which only shows you the regions.. What I think is that it should always be possible to have free names for the regions. No matter if i call - the region where my content appears in - 'content' or 'site items'..

See attached screens..

Stefan Nagtegaal’s picture

nedjo’s picture

FileSize
13.39 KB

Here's a revised patch implementing some of the ideas so far. I've used the theme engine - rather than individual themes - to generate the list of available regions. I know this isn't ideal, but e.g. for xtemplate it's at present the only option--no logic is possible in the individual theme.

region is changed to a varchar field from the current tinyint.

I've roughed in several regions--really just for demo purposes. More thought and work would be needed to refine them (e.g., styling, etc.). But this maybe moves the conversation forward.

Dries’s picture

This patch enables different regions to be used. That is a good thing. The next question is: should we take into account that different themes could assign blocks to different regions? Lots of problems would be solved if (i) there could only be one active theme on a website or (ii) if all themes would have a common set of regions.

(This "let users select their own theme"-thing is a left-over from the early days, except for WAP stuff maybe.)

killes@www.drop.org’s picture

Giving up multiple theme support would be a great thing. People could still select from multiple style sheets. WAP shoud not be a user preference setting, but automatically detected and redirected to a special site with a WAP theme.

adrian’s picture

You would then lose the ability to make a special front page theme for use with the sections module, for instance.

Also, currently styles exist in the same namespace as themes, and we would have to make more a distinction of styles vs templates (or themes), but I do think this could help simplify things.

nedjo’s picture

FileSize
15.69 KB

The main issue raised, if I'm understanding well: if a theme or theme engine is present that offers regions other than those available in the default theme, any blocks assigned to those regions will be invisible to most users.

Here's a revised patch addressing the concern. I've added a test for each region to see whether it's also available in the current default theme. (Actually, I'm realizing as I write this, I've used the theme engine--so it would need to be updated to test first if an engine is being used.)

In any case, any regions not available by default are starred, and a message text appears (only if necessary).

If there's support for the approach, I'd be happy to finish the patch. Remaining work:

* extend to work with non-engine themes
* finalize base set of regions to implement
* implement common region set in all core themes (for now I've only done xtemplate)
* work on CSS display (how blocks in each region should look)

This last point I'm not too confident on and would look for help/suggestions.

Screenshot to come.

nedjo’s picture

FileSize
12.34 KB

Screenshot showing starring of non-default regions plus message.

killes@www.drop.org’s picture

I like that approach. +1

resmini’s picture

My two cents.

If this has to be done (and it should), better get rid of spatial definitions for areas such as left, right, top, bottom, etc.
Use semantic names related to content and let the theme take care of their positioning interely.
Also note that there in an ongoing debate in IA trying to build up a standard naming convention for page regions in a way that is semantically (and logically) correct. Just for the sake of it, you can check

http://www.stuffandnonsense.co.uk/archives/whats_in_a_name.html
http://www.stuffandnonsense.co.uk/archives/whats_in_a_name_pt2.html

with follow-ups, including Eric Meyer's. There are more substantial contributes in the AIfIA web site, but I can't seem to find them now. I'll post a link or an abstract if I manage to.

--

vector at exea dot it

nedjo’s picture

Good points, useful references. The default regions I'm thinking of are:

       'banner' => t('banner'),
       'left' => t('left sidebar'),
       'right' => t('right sidebar'),
       'body_top' => t('body top'),
       'body_bottom' => t('body bottom'),
       'footer' => t('footer')

Perhaps "body" would be better as "content"? It would be easy enough to add in more regions, e.g., within the content (after title, after help, etc.) One issue is that many of these regions will already have rendered content. Should the blocks come before or after that other content? I've assumed after for banner and footer, while giving both options in body.

In any case, refinements or suggestions would be great.

resmini’s picture

Well,

'banner' => t('banner'),
'left' => t('left sidebar'),
'right' => t('right sidebar'),
'body_top' => t('body top'),
'body_bottom' => t('body bottom'),
'footer' => t('footer')

The classic (as far as classic goes for something Web related) scheme comprises 5 spatial regions, much like stefan's http://drupal.org/files/issues/regions---possibility-1.png with a left area mirroring the one called 'blocks'. Call them top, left, center, right, bottom.
Variants usually exclude one or more of these, layout-wise.

If we talk content (semantic) instead, things get a bit more complicated, as these spatial regions normally include more than one content-area. The top, for example, could include ad banners and the site's header, or the main menu. But these merge seamlessly with CSS definitions, which are definitely something that should get properly standardized (most of the errors / inconsistencies I'm encountering with Drupal today are related to this), but this is out of scope in this thread.

What I somewhat object to the definitions above is that it mixes the two approaches.
'banner' is not spatial, is content, as it is the distinction between body top and bottom. If 'banner' goes there, it is 'top', whatever that might be. I designed a couple of web sites which had headers/logos/banners at the bottom of the page, and I'm not exactly the wildest designer you'll probably meet.
And if we include body_top and _bottom, we should also add 'navigation', or 'menu' and some other content-related semantic region (impressum, or company_data, or whatever).

I suggest that either we go along

'top' => t('banner'),
'left' => t('left sidebar'),
'center' => t('body'),
'right' => t('right sidebar'),
'bottom' => t('footer')

or we dedicate some time to detailing what could possibly fit there semantically, which is perfectly possible without limiting design freedom or whatever, since the vocabulary is not infinite, but not something you do out of the blue.

Please note that I understand t('something') to be an example, since such a layout only defines regions on the page, not semantic regions. My main content could fit nicely in the bottom region.

As for the names for the regions, they are not important, as much as they are coherent and enforced.

Stefan Nagtegaal’s picture

FileSize
2.39 KB

Maybe something like this???

But, I have to say that I _really_ liked the solution to split the 'content'-region into the 'content' and 'beneath content'.. I love that!

resmini’s picture

Stefan, yes.

That's basically what you can build if you stick with spatial, and this layout can generate quite an amount of (sane) layout variations even if you interpret it strictly (suppose a default) as

<div id="header">
</div>
<div id="left-bar">
</div>
<div id="content">
</div>
<div id="right-bar">
</div>
<div id="footer">
</div>

What you can do with this is left basically to the theme designers and their use of CSS, CSS-P or tables (brrr), but this could be an easy and proper way to identify macro-regions in which more accurate positioning happens at a more specific level.
I'm all in favour of subsequent identification of sub-areas (top and bottom in body), but I don't think it would be a good idea to mix the different approaches I mentioned in my previous post.
A site with lots of things going on or which is not just blogging surely has the need to use its content area in a wiser manner than just putting there 'content', the number of modules doing precisely this is more than proof, but that falls more in a 'Drupal definitive guide to semantics', in which CSS selectors are used or suggested strategically for such a scope.

From this point of view and for the sake of this thread, any unique area / div (#name) could (should?) be a target for blocks, and this in my opinion (*) would be the perfect solution, but I do not know if and how this is even remotely possible in the current Drupal.

(*) It's quite late, local time, and it was a looong working day.

resmini’s picture

Just to be clear, I add a variation of stefan's scheme that shows how this is not by any means positional, but spatial, or better relational. Use your CSS imagination to take out regions, reduce them to empty containers, enlarge them, make them taller, shorter, whatever. 5 regions, do what you like.

resmini’s picture

Sorry, I forgot.
And this is also why I'm not too keen on calling anything 'content'. If I enlarge my right region enough, why not put my content there? Shouldn't this be a theme-level concern?
It's nothing serious, but if my center area is called 'center' (or something similar and more sexy), I won't confuse anybody.
This is left, center, right: do with them what you prefer. Content in the bottom? Show me.
If I call something 'content', I'm more than suggesting that content goes there, and only there.

Stefan Nagtegaal’s picture

Resmini, maybe it is only me but I think that you are making a mistake in your way of thinking..

I get the feeling that you're mixing the 'regions' and 'divs'.. the 'regioins' should have meaningfull sentences, but the divs shouldn'thave..
As an example:
$region_name => $content_body

here we go:
'header' => $logo
'left sidebar' => theme('blocks', 'left')
'right sidebar' => theme('blocks', 'right')
'content' => $content
'footer' => $footer.

So, $region_name does not have to be equal to the id or class of the divs..

resmini’s picture

Stefan,

>So, $region_name does not have to be equal to the id or class of the divs..

Yes, absolutely. I probably didn't make myself very clear: what I'm trying to point out is that in

'header' => $logo
'left sidebar' => theme('blocks', 'left')
'right sidebar' => theme('blocks', 'right')
'content' => $content
'footer' => $footer.

there is no reason at all to call 'content' the region that holds $content.

nedjo asked in #24

'body_top' => t('body top'),
'body_bottom' => t('body bottom'),

if Perhaps "body" would be better as "content"? and all my reasoning is simply that no, that is not content, or it shouldn't be (or better: it may happen that main content is elsewhere). As a matter of fact, even the connotation 'sidebar' doesn't fit very well logically.

To make it short: Today's method works, but has limits. Mambo, which paragkenia quotes at the beginning, handles more 'user regions' but in pure Mambo style conventions are so loose that they are hardly useful.
If we define regions, as in nedjo's example, in my opinion these regions shouldn't imply informational layouting, only relational positioning (that is, where they stay in the browser viewport).
I know it may look like overdesigning, but Drupal constantly enforces conventions and coding guidelines everywhere: this is one of the best aspects of the project and I think it should carry to the layout.

Stefan Nagtegaal’s picture

While I think that 'body_*' is not as self explaining as 'content_*' I vote for using 'content_*'..

chx’s picture

Let's get back to the code. If my understanding is correct the big discussion is about how to name potiental rectangular areas _after_ this is commited. So, first get this committed. What's need to make that happen?

chx’s picture

I spoke with Moshe, Steven, JonBob and the result is: keys shall be numbers, and themes shall define the values. We will make region zero and one required. There will be a define('REGION_CONTENT', 0) and a define('REGION_SIDEBAR', 1); so you can have readable code still. Either wait for me to code it or feel to do it yourself, just drop me a mail via the contact form if you are doing it.

nedjo’s picture

Károly, it's great if you're willing to take on finishing this. I tried to summarize remaining work in update 20, above.

The numerical keys look fine to me.

In terms of an initial default set of regions, one quirk is this: for now, so far as I can see (and assuming the approach I sketched in), available regions can be defined only in (a) theme engines and (b) individual themes that don't use an engine. So, for instance, an individual xtemplate based theme can't define its own custom regions; they need to be defined in the theme engine. (Unless and until the whole theme system should switch to the sort of configuration file adrian suggested above.)

Which is to say that, under this approach, we'll be defining a set of regions for each engine, and then all themes using that engine should try to implement those regions. (Otherwise, if a site admin selects a region defined in the engine but not implemented in the default theme, the content won't appear.)

Please let me know if there's anything in what I've done that isn't clear, or if you want to pass some or all of this back.

Thanks!

chx’s picture

I had a "short" discussion with the UI team leader ie. Ber Kessels. The outcoming is that we will change hook_block so that it uses callbacks a bit like menu system. Here's an example:


function module_block() {
    $items = array();
    $items['module_header'] = array('callback' => 'mymodule_page', 'weight' => -50, 'region' => 'content' , 'cache' => TRUE, 'pages' => "node/*\n");
    return $items;
}

Please note that we are allowing caching the themed output of each block independently.

The theme system will execute hook_block as it does now and it'll execute the callbacks defined in module_block as well. Of course if the callback is cacheable and in the cache, it'll print it from cache. If it's themeable and not in the cache, it'll cache it before printing.

Pages contains a string (could be PHP code!) which can be overriden in the block configuration screen.

Callbacks defined in hook_menu will have lot less functionality after this, they will be used for non-themed pages mainly.

chx’s picture

More explanation is requested for the example.

module_header is the unqiue name of the block.
pages define on which pages the block is visible. ('pages' in the block configuration screen.) Maybe I'll implement 'visibility' from the same screen as well.
callback, weight are well known Drupal terms.
cache is a boolean which defines whether given output is cacheable or not.

chx’s picture

Ber, Dries, do not kill me! Ber chaired the usability meeting in Antwerp, that's all.

Bèr Kessels’s picture

FileSize
123.29 KB

attached is a schematic which might clarify this a little.

And I would also like to comment on me being the UI leader: I do not consider myself any leader, no ofeence, though. Just to clarify that.

nedjo’s picture

I am not opposed to the idea of changing the _block() hook to use callbacks (I have no opinion on it, not immediately grasping the need), but this seems quite distinct from the aim of enabling multiple and extensible regions. Why can't we just move ahead with the block generalization?

I suggest:

* quickly implement the proposed block region generalization, using only the two existing regions (i.e., implementing them in core themes)
* later worry about:
- adding further regions (the details of which are best done by those primarily responsible for the particular themes)
- possible changes to the _block() hook.

Wouldn't this make sense? Or am I missing some pressing reason for which the block generalization has to wait?

killes@www.drop.org’s picture

"Or am I missing some pressing reason for which the block generalization has to wait?"

I might be missing something too, but I thought Chx was just talking about the block generalization and proposing a way to code it.

factoryjoe’s picture

I wanted to chime in with this discussion because it's an important one and has some really huge implications for Drupal moving forward. That said, I also have a day job pulling all my attention which means that the big ideas I have for this problem can't be put into a complete visual form for at least a week or more. In the meantime, I'd like to offer a few thoughts on the matter.

  1. Regions do not belong in themes. Blocks were originally separate from themes for a reason. Themes should define the general look and feel of a site -- and to some extent a site's behavior. Layouts which define the spatial relationship between regions belong in some intermediary between style and content, which does not currently exist in Drupal.
  2. I would propose that layouts become a new kind of CCK tool. By that I mean that they can be defined, shared and deployed very easily -- even as simply as tossing a directory of some .layout textfiles into a layouts/ directory. Note that this suggestion has nothing to do with the way CCK might actually work right now; instead I'm suggesting how I would like it to work. I would like, for example, to create a CCK item like a "person" and ship it with a .layout file that carries all the semantic goodness needed to output that "person" to the screen in juicy, semantic markup... which anyone can come along and theme to their heart's content.
  3. Creating shareable layouts should be relatively painless. Dashboard sets the bar for easy hackability. It should be that easy to create layouts for Drupal... I can imagine creating an "iTunes layout" or an "Image Gallery" layout and so on... If we used something akin to PHPTal to develop the layouts, we could keep development fairly standard while making it possible for more folks to hack up cool and innovative layouts.
  4. Layouts should be extensible.. to a degree. I see a huge problem with how this discussion has floated back and forth between semantic and spatial region naming. Because we talk about this problem in those terms, we fail to identify the real problem and opportunities presented to us. Here's the thing: when you predefine regions, you limit creativity and the ability of people to really use the system. On the other hand, when you make a system too flexibile, it quickly becomes unwieldy. In all the mockups presented above, both classes of problems would arise. Therefore we need to think about a way to stay flexibile while "taming the beast."
  5. To that end, I suggest developing self-contained layouts that are contextually-complete. So for the example of the iTunes search layout... you would know before hand that you get a couple multiple select boxes that you can hook up to whatever taxonomies you want to progressively filter [nodes]. You could even change the .layout file, allowing you to theme it to your liking -- even though that would totally optional, given the layout's internal default styling. Once you've got your layout, you would go into a layout module UI, create a new layout, select the layout from a list and then give it a path so you can access the layout... You would then walk through a wizard that would help you populate that layout with all kinds of nice Drupally goodies... feeds, node listings, PHP code, etc.

The power in this approach is multifold. For one, it snaps Drupal out of its block mentality and allows designers to really innovate with individual page designs. In fact, I've already thought out how I could reimplement Flickr using this system, combined with Drupal's native feeds, taxonomy and menu module, and I'd barely break a sweat... sort of. ;)

But anyway, this is a very productive conversation to be having, but I really think that we should consider whether the old paradigm, as such, really pushes Drupal as far forward as we have the opportunity to go.

chx’s picture

While factoryjoe may be right, I could be right as well.

Regions has definitely something to do with themes, after all it's the theme that renders the page, and it can only render regions that it knows of.

So, instead of postponing this into the far future when someone comes out with a layout system, I code this now.

Dries’s picture

The proposed 'weight', 'region' and 'pages' would be configurable, not? Are these just defaults? The 'callback' and 'cache' options are nice to have.

chx’s picture

Yes, blocks can provide a default for everything on the block and and configuration screen. Of course, you can override these in the UI.

Bèr Kessels’s picture

Dries: yes, the region, weight and pages will be configurable from an admin interface. What we tried to address here, is a method for developers to choose good defaults. Take for example "logo". that should be enabled by default in a regions called header, rendered on all pages, and have a very light weight. We should not force an admin to visit the blocks admin before she can see or use the logo.

Chris: I do not know if you have ever tried typo3. Its concept is some form of builder system. I do not like thar, because far too complex. If we ever get sme kind of builder in core (if ever) it will require a lot of work, and even more usability research. So for now such a builder is far out of our reach. Lets aim at goals that are more realistic ;) So: it does belong in themes, its the best place that is still realistic.

I do like your visions, Chris, but I hope you agree they are not realistic, yet. So, maybe you can think of a path towards your visions, ow we can reach such a builder-system, you describe?

factoryjoe’s picture

My browser crashed before I was able to submit my followup to chx's comment... I have no problem with the current work going forward and am happy to see it happening. I know that my ideas are typically outlandlish and far off... That's the kind of design I enjoy doing!

In any case, I see chx's solution being a means to an end; once we have abstracted the region code, it become much easier for me to get some help creating my vision.

In the meantime, and as a demonstration of how I see this layout system working (to answer, I hope, Ber's concerns about clunkiness), I've created a workflow movie that shows off how fast you'd be able to add content to the system.

Check it out:

http://factorycity.net/demos/civicspace/layout/media/layout_workflow_v1.mov

Feedback appreciated. And, if you want to try the demo out yourself (it's all hardcoded, like a "movie set" for my UI), go here:

http://factorycity.net/demos/civicspace/layout/

nedjo’s picture

FileSize
13.56 KB

I might be missing something too, but I thought Chx was just talking about the block generalization and proposing a way to code it.

Well, if I can say so respectfully, I don't think so. Not so far as I can see identifying problems with my original patch, this interesting discussion is rather addressing the (useful, but logically subsequent) question "once we have multiple regions, how should we work with them?". It's perhaps demonstrating our propensity to try to do more rather than less with a given patch--to talk for a long time when a first step solution is already in place. So here is a (yes, interim!) small, focused, and tested patch to remove the hard-coded regions. I've stripped it down so it does nothing more than (a) make block regions declared by themes rather than hard-coded and (b) implement the existing left and right regions in existing core themes. Please, try it out, I think you'll like it. I'm of the (I'm hoping not scandalous) opinion that it can be applied right away, and so clear the way for further progress. In particular, this patch leaves the adding and configuring of additional regions to theme authors/maintainers, who are best qualified for the work.

I spoke with Moshe, Steven, JonBob and the result is: keys shall be numbers, and themes shall define the values. We will make region zero and one required.

The reason I moved from numbers to strings (e.g., "left") is that a theme author defining regions has no way of knowing what regions might have already been defined, and therefore what integers might have aleady been used. It's like module and theme names--we'd have to use random numbers to avoid conflicts, so we're better off with string names.

Bèr Kessels’s picture

nedjo,

I am not a fan of your solution for blocks that dissapear. It breaks the ability to allow more themes on a site. if important blocks dont show up, your site will simply break. I would rather suggest that every theme MUST have a region called 'default'. any blocks that want to go into a non-existing region, will be placed there.

We must define a standard listy of suggested region names. to avoid a wildgrowth of names.

I am not sure if i like the way you do function phptemplate_regions(). these regions should be defined in the templqtes, not the engine. Otherwise all phptemplate themes will still all have two regions.

Note that i did not test your patch thouroughly, just applied and looked at.

nedjo’s picture

Thanks for your comments. I think we're getting somewhere.

I am not a fan of your solution for blocks that dissapear. It breaks the ability to allow more themes on a site. if important blocks dont show up, your site will simply break. I would rather suggest that every theme MUST have a region called 'default'. any blocks that want to go into a non-existing region, will be placed there.

Good suggestion. Having a default region for blocks to show up sounds like a valuable backup. I'm thinking we might want to have a way to designate a given region as the default, rather than having to have one named 'default'. Thoughts?

We must define a standard listy of suggested region names. to avoid a wildgrowth of names.

Sure. But the patch doesn't prevent doing that--it enables it.

I am not sure if i like the way you do function phptemplate_regions(). these regions should be defined in the templqtes, not the engine. Otherwise all phptemplate themes will still all have two regions.

Oh, I wholeheartedly agree, and I've noted the issue above. But unless we substantially rewrite the engines, some region definition is needed in the engines, as they call blocks. Should we therefore define a base set in the engine, then call a hook from the engine to add any other regions from themes based on that engine? If so, where in the theme's files should such a hook be located?

And a side note. Do let's make an effort to keep our comments friendly. Taking the time to note one or two things that do work or are done well as part of a review is I believe a valuable habit. It helps to confirm what is indeed accomplished. Beyond this, it helps to maintain the idea that we are collaborating on shared goals, rather than pushing individual and competing visions, and that contributions and work are appreciated, rather than being invitations to criticism.

Thanks, Nedjo

chx’s picture

I am implementing http://drupal.org/node/16216#comment-29282 but it takes time. regions again have names. default and sidebar regions are mandatory.

This has little to do with nedjo's code much more with his idea -- I looked at the screenshot and said, OK this is great but... we'd like to have a lot more 'blocks' if this comes through, henceforth the above mentioned solution.

nedjo’s picture

Okay, thanks for the clarification, I hadn't understood that you were taking a new approach rather than building on what I'd begun. Given that that's the case, staging as I'd suggested obviously won't work so I'm content to wait and see what you accomplish. I'd only suggest, don't feel like you need necessarily to do everything all at once.

Bèr Kessels’s picture

Nedjo, sorry if the sound of my comment was hostile. it was never meant to be that way. I am busy, and thus did not want to comment all the things i liked about your patch, but chose to pick the much smaller amount of things I thought could use some improvement. I will try to keep in mind to be more friendly next times. Also, not all of us are as fluent in English as our native English speakers. I think its good to keep in mind that for a lot of us, communication in English is not as easy as it may seem. For me, it often requires a lot of concentration to get the subtleties right. I mean: I can type some English text, look up words in the dictionary, but to get small yet important subtleties in my texts is very hard, often.

But, that all said: I liked your patch.

jakeg’s picture

How far off is this from being officially released or at least usable?

If its usable now, what files will I need to implement it?

Kobus’s picture

FileSize
2.21 KB

To add to Stefan's suggestions with the two screenshots, I modified one of them a bit, and this is how I understand Jaza's post, and yes, I agree, this would be a wonderful feature! I can't wait! Imagine how good it would look if I had a theme that has a clear white background (not visible blocks) and then these seemingly random boxes on the page, as shown in the screenshot. Especially where I can place it anywhere around the node like Jaza said with a [region:2] block etc.

I say again: I can't wait!

Kobus

chx’s picture

I need 3-4 hrs of peace to implement the callback based thing. That's a lot these days. Let's hope I'll get on it in the following days.

chx’s picture

Here's an example again of how hook_block will look like:

function module_block() {
    $items = array();
    $items['module_header'] = array('callback' => 'mymodule_function', 'callback arguments' => arg(1), 'weight' => -50, 'region' => 'content', 'cache' => TRUE, ''pages' => "node/*\n");
    return $items;
}

Items are keyed by unique IDs. The template system will call module_invoke_all('block'), put the rendered HTML of the blocks into regions sorted by weight. The rendered HTML is cached if it is allowed. More keys will be introduced later, but now basically we just throw everything from block configure in here, and add callback, callback arguments, region.

Node teasers or fullly rendered nodes are blocks, too. Almost everything is. So, here what happens when we are on taxonomy/term/1:

taxonomy_render_nodes is called
it calls block_set('node_view', $weight, $node, $teaser, $page); a few times, so a few node_view blocks will be on the page
later the theme system is invoked. It will ask the block system to collect all blocks, dynamic and the static blocks as well. For all dynamic blocks we have a block defined in hook_block somewhere, like the definition above, with one exception: it will have a 'standalone' => FALSE pair, so it is not a standalone block which is automatically rendered but something that needs to explicitely requested. Also, we may define a 'suffix' => 'somefunction' pair which provides us with a cache ID suffix. Look at the code below:

function block_collect_blocks() {
  // get all block definitions
  $static_blocks = module_invoke_all('block');
  // iterate of the dynamic blocks set on the page
  foreach (block_get() as $dynamic_block) {
    // get the block definition for the given dynamic block
    $static_block = $static_blocks[$dynamic_block['block']];
    // merge the callback arguments from the dynamic and static. dynamic_block['callback arguments'] is always set though
    // may be empty
    if (isset($static_block['callback arguments'])) {
      $dynamic_block['callback arguments'] = array_merge($static_block['arguments'], $dynamic_block['callback arguments']);
    }
    // try to get a cache ID suffix
    $suffix = function_exists($static_block['suffix']) && call_user_func_array($static_block['suffix'], $dynamic_block['callback arguments']);
    // if the block is cacheable or the suffix function says that it is cacheable by setting a suffix
    if ($static_block['cache'] || $suffix) {
      // set cache ID
      $cid = 'block:'. $dynamic_block['block'] .':'. $suffix;
      // try to get the rendered HTML from cache
      if ($block_rendered = cache_get($cid)) {
        $return[$static_block['region'][$dynamic_block['weight']][] = $static_block_rendered;
        continue;
      }
    }
    // render the block
    $block_rendered = call_user_func_array($static_block['callback'], $dynamic_block['callback arguments']);
    // store the block for return
    $return[$static_block['region'][$dynamic_block['weight']][] = $static_block_rendered;
    if ($static_block['cache'] || $suffix) {
      // if cacheable, do it
      cache_set($cid, $static_block_rendered);
    }
  }
  foreach ($static_blocks as $key => $static_block) {
    // is this a stand alone block, like in Drupal 4.6?
    if ($static_block['standalone']) {
      // now, the above is repeated, save that we do not have a dynamic_block here
      $suffix = function_exists($static_block['suffix']) && call_user_func_array($static_block['suffix'], $static_block['callback arguments']);
      if ($static_block['cache'] || $suffix) {
        $cid = "block:$key:$suffix";
        if ($block_rendered = cache_get($cid)) {
          $return[$static_block['region'][$static_block['weight']][] = $static_block_rendered;
          continue;
        }
      }
      $block_rendered = call_user_func_array($static_block['callback'], $static_block['callback arguments']);
      $return[$static_block['region']][$static_block['weight']][] = $static_block_rendered;
      if ($static_block['cache'] || $suffix) {
        cache_set($cid, $static_block_rendered);
      }
    }
  }
}

function block_set() {
  static $blocks;
  $args = func_get_args();
  if (count($args)) {
    $callback = array_shift($args);
    $weight = array_shift($args);
    $blocks[] = array('block' => $function, 'weight' => $weight, 'callback arguments' => $args);
  }
  return $blocks;
}

function block_get() {
  return block_set();
}

When to expire the block cache? Never. If functions can call cache_clear all, they can be smart enough to cache_clear only those blocks that are changed by them. Some blocks won't be cacheable anyways, say there is little use in caching 'active forum topics'

Dries’s picture

Frankly, I don't understand what you are trying to say. What is a 'dynamic', a 'static' and a 'standalone block'? What is the suffix for? What is the advantage of making node and taxonomy views blocks? If there is no big advantage, this is just bloat. All in all, it looks pretty complex to me.

If we make Drupal more flexible _and_ more complex, people will get upset, and we end up being like Plone. Drupal's simplicity is something to foster, as it allows people to go in, and change stuff. The focus is to make Drupal simpler _and_ more flexible.

I merely spent 10 minutes looking at this (reading your explanation twice, staring at the code), and the newly added complexity simply turns me off. Maybe that is because I don't understand what we are gaining.

Bèr Kessels’s picture

* The first thing we gain, is, very slmple: more regions.
But, how many? what regions? on what pages? in what location? bearing which name? For all these issues we need some callback system. To allow themers, administrators and module developers to give answers to all these questions. what we have now: sidebars, with only admin settings, is simply too limited: It takes serious hacking (~15 lines of code in your theme) to get a login block in your header!
* The second thing we get for free: We are passing along chuncks of HTML, so why not cache them in a central place.
Practice points out that our current cache is not used well. We leave it to developers to cache. And developers are lazy by nature. Just looks at all the places where caching should have been done, but is not. 9/10contribs have at least one of these places.

You must actually see these issues separate. The new central blocks pulling system, and the caching. the latter is something that we get for free, a high level of advanced caching (how often has not been put forward Drupal seiously lacks better/advanced caching?). But we get it only for free if it is co-developed with the new regions blocks.

And Last but not least, everything is a block, from a themer point of veiw. I know developers tend to think: I do the content, and do not care about where and how it turns up. That results in a content-centric system, what we have now. Everythng is built around aa single chunk of content. while, in fact content, is yet another block. Look at http://www.terminus1525.ca/index.php?l=en or http://www.franklinpennsylvania.us/ as it stands now, its up to the developer to concenate all the HTML in the center area, into a huge chunk of HTML. While in fact everyone can see that these are a lot of separate blocks.

Dries’s picture

Ber: I was talking about chx's latest changes, not the block system in general.

nedjo’s picture

I appreciate the update on directions being contemplated, although I find it confusing.

Again, I'd caution, let's keep focused on the aim at hand, and on a staged solution. A bigger patch means greater complexity, more difficulty getting meaningful review, and greater delays in getting a priority change. We're currently in a position where we have two hard-coded regions for blocks, a major issue if nothing else than because it reflects poorly on Drupal's usability and versatility. Moving from here directly to something like "everything you see anywhere is a (nested) block in its own (nested) region" strikes me as a bigger step than we need to take.

And in belated reply to Ber's note (#53 above), thanks for the thoughtful comments, I didn't mean to single you out and acknowledge that language & cultural differences play a role, I feel we can all benefit from attention to communication.

Dries’s picture

Even with the explanation in chx's sandbox, this is too complex for my likings. Here is a suggestion: let's drop the caching and the 'suffix'-stuff. Let's also drop the 'complete' and 'incomplete' stuff. Keep it _simple_, chx. IMO, you're creating a monster.

chx’s picture

nedjo, take over. I am out.

djnz’s picture

Quick and dirty solution? Let blocks be assignable to 9 locations - Top left, middle, right, middle left, middle right, bottom left, middle, right.

The actual location of these areas within a theme is up to a theme designer, but the designer should include each of them - how about $sidebar['tl'], $sidebar['tm'], $sidebar['tr'] ...

Backwards theme compatibility could easily be maintained by only creating the $sidebar array if the theme has set (eg in its template.php file for a PHPtemplate theme) a flag, otherwise generate $sidebar_left from the blocks set (in sequence) to top left, middle left, bottom left, top middle and middle middle (arbitrary break) with $sidebar_right the remainder.

I appreciate I have no karma here and only superficial knowledge of the Drupal code, but sometimes the clarity of a view unclouded by too much information is useful ;)

nedjo’s picture

FileSize
24.74 KB

nedjo, take over. I am out.

Um, okay. I've given the question some more thought and come to the following conclusions:

1. If we take regions to be areas of the page that specific types of content are rendered into, and a regioning system to be a system to accomplish this, we already have a number of regions and different types of regioning systems. They include:
(a) our current blocks system, and
(b) the various drupal_set_[region]() functions, like drupal_set_comment().
(c) specialized hooks like our help system, which assembles content to be rendered into a region.

2. LIkely we should tease out regions from blocks.

So attached is a next rough cut at regioning. Features:

* Default region is defined in general admin settings page
* Regions are defined in both engines and themes. A particular engine-based theme has the regions it defines plus the engine's default ones.
* Content can be written to regions in two ways: through blocks or through drupal_set_content($region, $content) calls.

Initial comments are welcome. I'll work on getting a more polished patch and also more explanation of the approach.

deekayen’s picture

Disclaimer: I offer no code for this, so this is just a bunch of idealism I can't back up.

djnz's comment makes sense if you want quick and dirty, but it seems to me the correct way to do things would be in terms of relatives. I would think doing it right the first time would be easier than redoing block location code twice. For example set a standard starting location; perhaps the start is 100% height/width conceptually. If you want to put something on the right, it would be the first block on the right of the starting block - let the theme manage widths. Then if you want another block on the right, or 10, just keep adding them relative to the others kind of like the current ordering of book pages or like adding more TD cells in a HTML table.

Using this example under the current standard layout, the main block could be in the middle with with relative blocks on the left and right.

arnabdotorg’s picture

It would be totally awesome to see multiple regions in Drupal 5, if not 4.7.

This topic has been discussed several times before, noting them down for reference:

http://drupal.org/node/2790 [September 9th 2003]
http://drupal.org/node/10653
http://drupal.org/node/13008

I also think it would be nice to have people implement multi-region themes; see what problems we encounter, and learn from it.

arnabdotorg’s picture

Forgot to add, I've patched nedjo's final patch to Drupal HEAD, it's up at http://arnab.drupaldevs.org/.

nedjo’s picture

FileSize
25.03 KB

Here's an improved version of the patch--several bug fixes, no new functionality. There are still a couple of loose ends (e.g., implementing the option of particular blocks not to be themed), and I haven't fully tested it.

Further to my previous explanation, here is a summary of what the patch does. I'll mark as "new" the bits added in this week's iteration.

Problem addressed:
Currently, Drupal has two hard-coded regions into which block content is rendered: left and right. This situation severely limits the flexibility of content presentation.

Aim:
Enable multiple and extensible regions for blocks and other content.

Approach:

1. Hard coded regions are removed from block.module. Instead, available regions are loaded dynamically.

2. Available regions are defined in themes (and, optionally, in modules). A theme or a theme engine defines its available regions through a themename_regions() function in themename.theme file or a enginename_regions() function in an enginename.engine file. New: engine-based themes can define their own regions in a .theme file. They will have all the engine's regions plus any they define. New: modules can define their own regions through a hook_regions() call. This should allow modules to define and use "inline" regions. For example, a module could define a region, then use a nodeapi() call to load content for that block and then insert it into a formatted box in $node->body.

3. New: the regions associated with a theme are loaded as part of the system_theme_data() call, and available regions are loaded through a system_region_list() function.

4. Previously stored as an integer, blocks' regions are changed to varchar, to enable storing of strings (e.g., 'left').

5. A "default" region is defined (as a core setting), into which content will be rendered in the case that it's assigned to a region that's not available in the current theme. The options available for the default region are "core" regions, defined as all those available in all available themes. In the main block admin page, all regions not available in the current default theme are marked with an asterix, with an explanatory note.

nedjo’s picture

FileSize
1.13 KB

Here's a sample module using the patch's regioning. When installed, it visually marks all available regions when you visit the page ?q=showregions. This is implemented using the proposed system_region_list() and drupal_set_content() functions. (I've attached a .txt extension to the module file since otherwise module files seem to get rewritten when uploaded.)

nedjo’s picture

Component: block.module » base system
Assigned: Unassigned » nedjo
FileSize
28.83 KB

Okay, this is now ready for review.

To install after applying the patch, run update.php, since some database fields need to be created and updated (see function update_141() in the patched update.inc).

In this final version, I've:

* simplified the handling of content assigned to regions not available in the current theme, by loading such content directly in theme_blocks(), so that no custom handling is required in themes.
* finished the coding for designating particular blocks (including custom ones) as not themed, so that it's possible simpy to inject content. This introduces a new 'themed' parameter of blocks.
* made several variables configurable in the declaration of blocks by modules. As well as $block['content'] and $block['title'], you can now set $block['status'], $block['weight'], $block['region'], $block['themed'], $block['pages'], and $block['custom'].

To see the behaviour, set any phptemplate-based theme, or chameleon, as the default theme. In the blocks configuration page, configure blocks to go to display in various regions. Note that, as chameleon has only two regions (left and right), all others are written to the default region (set in the main settings page, under general settings).

I believe this iteration answers all major outstanding requests for functionality. It also, I hope, leaves the way open for the sort of caching and other block system enhancements chx was working on.

I've taken this patch as far as I can. I'm committed to basic fixes before or after it's applied, if such are needed. But if what's wanted is another major rewrite, we'll need someone different to take it on.

Reviews and comments, please!

Bèr Kessels’s picture

Nice approach!

One thin i dislik though (read this as: I like the rest) is the configuration for a default region.
1) it adds clutter.
2) I cannot think of any theme that will not break when I statr putting lots of content other than ni the place the theme wants it to be.
3) This should really be up to the themer. A theme should provide the default region, not the administrator.

Dries’s picture

The patch no longer applies ...

Looking at the code, I wonder whether the 'themed' stuff makes sense. A theme might want to theme different blocks differently based on their ID. Not theming a block is a special case of this and is already possible. Allowing the designer to set IDs that he or she can intercept, makes more sense to me. The themed-field gets a -1 from me, but I might reconsider after having tested the patch.

Looking at the code, I wonder what happens when one theme calls the sidebar "left sidebar" and another theme calls it "sidebar left" (words in different order)? Is there any limitations to the current approach?

nedjo’s picture

FileSize
25.73 KB

Here's an updated patch.

I've removed the "themed" functionality (which gave the option, mostly useful for admin-defined blocks, of inserting content directly without it being themed). It wasn't necessary to the patch. I might consider submitting it as a separate patch, but in fact I think the main issue it addressed - that content often looked bad when inserted into areas like the 'content' region, and would be better without the theming - will be addressed as themes designate appropriate styling for these block regions.

I've also implemented Ber's suggested solution to the question of how to designate a default region for content assigned to regions not available in the current theme. Yes, it's better to leave this to the theme author--and since this avoids needing to create a new setting, it's a Good Thing.

Kobus’s picture

Inline blocks could perhaps also be used instead of absolute regioning. When patching the block admin page similar to uploads thread's screenshot (as shown here: http://drupal.org/node/26288) could improve blocks quite a lot.

If you look at the first screenshot, it shows a checkbox "inline" for each uploaded file. If this can be used in conjunction with [inline:xx] tags to have precise placement of the images as they state here, the same can be done for blocks, by means of a tag [block:xx] or something like that. given, that if you want to use that, you would need to know HTML (and have it allowed in nodes) to achieve this precision layout of blocks inside nodes by means of tables, for example.

I would really LOVE to see inline blocks together with inline images. The combination of these two elements can really provide for a total themed look instead of just blocks. I could, for example, have a node with two inline blocks, and another with no blocks and 3 images and one with one block and one image. This would break the left/right columns look completely, and, if you choose, eliminate it almost completely, as you can generate a "sticky" node at the top with the appropriate block inside it. I think that inline blocks is more important than more regions for blocks, but that might just be me :)

Regards,

Kobus

nedjo’s picture

Because my patch allows modules to declare their own regions, it should be easy to implement inline regions through a module, e.g., inlineregions.module. Something like:


/**
 * Implementation of hook_nodeapi().
 */
function inlineregions_nodeapi(&$node, $op, $arg = 0, $arg2 = 0) {
  switch ($op) {
    case 'view':
      foreach(inlineregions_regions() as $key => $value) {
        $node->body = str_replace ('[inline:' . $key . ']', theme('blocks', $key), $node->body);
      }
      break;
}

function inlineregions_regions() {
  return variable_get('inlineregions', array('inline1' => t('inline one')));
}

function inlineregions_settings() {
 // Interface to allow site admins to define regions by setting variable 'inlineregions'.
}

Kobus’s picture

I have no idea how to implement your code into a module as of yet, but once the new patch is approved, I will play around a bit with it :)

Thanks for the hint!

Kobus

Stefan Nagtegaal’s picture

While I _really_ want to see such a thing hit the trunk, I'll soon review/test this patch..

arnabdotorg’s picture

I'd really like this to hit core too...

(waits)

Dries’s picture

I just tried this patch. First reaction: I can only guess where my blocks will show up. I can't predict the result of making a change. The UI doesn't make me feel comfortable.

For this patch to succeed, we have have to limit ourselves to (i) having one theme, (ii) having a unified list of block regions or (iii) simply reworking the GUI so I have one selection menu for each of the available themes. Personally, I'm in favor of (i) but I'm sure some people are hooked up on the multi-theme thing.

While this patch is very powerful, it is also very confusing to use. I'd like to commit it to core, but I believe the UI / interaction design needs more work.

Bèr Kessels’s picture

+1 for he -only-one-theme-idea. As author and (well, no longer maintainer of) the onlye true multitheme druopal site (please get back to me if you have one too!!), I think drupal needs, above al, a one-theme-system

It will simplify a ot of code, including this patch , wich I like.

but, above all, i would like to see a "default" region. A place where themes AND module developers can trow their stuff when they dont know another place. It should simply replace the current MAIN area, really nothing more.

nedjo’s picture

FileSize
28.64 KB

Thanks for the review and comments.

Please try this revised patch. It provides highlighting on the block admin page, showing the location of each of the current theme's regions. This change is one UI approach to the issue of clarity around where content will appear.

I've also changed the patch to limit the available regions to those of enabled themes (previously it was all installed themes).

While I get the general point, I really don't see multiple themes as much of a problem. Don't want multiple themes (and the variability that goes with that, variability that, one hopes, goes beyond just this regioning issue)? Easy--don't enable more than one. I don't see any pressing need to strip out this functionality.

I've added the following text to the admin/theme help:

Note that different themes may have different regions available for rendering content like blocks. If you want consistency in what your users see, you may wish to enable only one theme.

That should cover it, shouldn't it?

nedjo’s picture

FileSize
20.75 KB

Screenshot showing the region highlighting on (portion of) block admin page, to give visual cue as to where content will go.

Dries’s picture

I tried the latest version of this patch. The highlights are nice but it doesn't solve the fundamental problem; it is difficult (impossible) to configure blocks when multiple themes are present. It's like having a global logo-setting, rather than a per-theme logo-setting. The global logo just won't cut it in presence of multiple themes. Because of that, the UI is rather confusing and the result of making a change is rather unpredictable. Unfortunately, I don't know how to fix this, except for removing multi-theme support. Anyone else has some thoughts on this?

Ber: removing multi-themes would have tremendous impact on stuff like your regions.module, or the possibility to have a separate admin-theme, not?

Stefan Nagtegaal’s picture

Can't we implement the multiple regions approach in the theme itself? And let the blocks api get the selected values. (And fallback when the theme is changed to the defaults 'left' and 'right')

theme_region_*() should be searched for in the template/theme by the block administration and return the values inside the dropdown/radiobuttons which are in the block admin..

I think that's more failsafe then the current choosen method.

nedjo’s picture

I've never personally had a need for multiple themes. I view the functionality as mainly a novelty. And, it's worth remembering, it would still be possible to have multiple styles, since styles based on the same theme would have the same regions. So, e.g., an admin style would still be feasible.

But maybe, rather than removing multiple theme support, we should simply change multiple themes to an admin-selectable option? (e.g.., in theme admin page, introduce "enable multiple theme support" checkbox. If checked, theme admin options are as presently, otherwise "enabled" becomes radios and "default" is eliminated). Add a message about the tradeoffs of enabling multi-theme support, so admins can make an informed choice.

Can't we implement the multiple regions approach in the theme itself?

I don't understand the suggestion. Could you explain this a little more? In the current approach, regions are loaded from themes. Alternately, if you'd like to code your suggested approach and offer it for examination, please go ahead.

moshe weitzman’s picture

Hmmm. In our current theme system, a style *is* a theme. For example, Bluemarine and Pushbutton are each themes, and each styles. Even though these 2 styles are likely to have the same regions, what Dries is proposing here would make it impossible to use both on the same page (without hacking something).

I like Nedjo's idea to hide the complex UI behind a checkbox, but still support multiple themes. Multiple themes can be very useful on occasion. I would hate to lose that.

-moshe

Eric Scouten’s picture

I'm fine with the idea of dropping multiple theme support. The only time I change themes on a site is when learning about the themes as a site developer. I never allow end users to change themes.

The closest I ever get is changing color or lead-in picture for various sections of the site.

jvandyk’s picture

So, this would render the taxonomy_theme module obsolete?

-1 for losing multiple theme support. Multiple themes are very handy, and one of Drupal's strong points.

Eric Scouten’s picture

I'm fine with the idea of dropping multiple theme support. The only time I change themes on a site is when learning about the themes as a site developer. I never allow end users to change themes.

The closest I ever get is changing color or lead-in picture for various sections of the site.

Dries’s picture

Note that there is no win-win situation here. As I see it, there are two options:

1. We keep multi-theme support and add multi-block regions. The drawback is that block configuration becomes confusing. This will affect 100% of the users. Note that I think it becomes confusing, you might think otherwise. Apply the patch, test it, and report back. Also note that in the long, I hope Drupal will be able to do more complex page layouts (page specific layouts). This might also be more complex in presence of multiple themes. Hard to tell up front.

2. We drop multi-theme support, add multi-block regions and simplify parts of Drupal. For 95% of the users this will be an improvement; most people only use one theme and for these people theme configuration will become simpler. Plus, they get multiple block regions. Unfortunately, for the 5% that uses multiple themes, this is a regression. (Note that we can still do CSS-tricks. How about an admin-theme? Can we do that with just CSS?)

(3. Ask some UI people to review the GUI. Maybe they can figure out a better way to approach this.)

Do we value (1) ease of use and simplicity or (2) complexity and flexibility?

Gábor Hojtsy’s picture

Dries, from where does that 5% come from? I am not sure that number is so low, although I cannot give a better estimation myself. The problem with judging this by ourselves is that we as developers mostly run more professional Drupal sites, requireing a distinct look, while quite a few (I don't know whether it is 1% or 16%) run with multiple themes to choose from, so that their site users are pleased. Problem is we have no data about the amount.

adrian’s picture

-1 for losing multiple theme support, at least on the back end.
Multi-theme support was one of the primary reasons I tackled the template system, and as such .. I am against it being removed.

Why don't we make sure that each of these block/setting pages can be instanced, per theme, and then provide a new contrib 'multi-theme' module, that adds the extra menu entries and allows you to configure each of the themes seperately, including when the themes show.

This would mean you have your theme select, and your theme settings and your block region settings by default. And if you have the module enabled, there's an 'additional' local task under admin/themes, which allows you access to the extra configuration pages.

adrian’s picture

(crazy idea)
perhaps we can use breaking out multi-theme support as a mechanism to provide specific named 'sections'.

So a 'section' == theme selection + theme settings + block configuration.

And we allow the developer to switch section based on rules. ie: taxonomy, node type, path or custom (php block).
And each of these sections have a weight, as to which takes preference. That might be more useful than how we have it now (ie: settings, overridden by settings per theme + seperate block configuration)

This would mean that the normal configuration only sets up the default 'section'.

(/crazy idea)

eafarris’s picture

My users like being able to choose their own theme, so, -1 on removing multi-theme capability, though they could probably be satisfied with a few style.css variants.

nathanwastaken’s picture

I use multiple themes, mainly for the seperation of admin pages and the general user pages. I also use it in conjuncion with a veriation on the sections module, to display slightly different themes, based on the users location on the site. This COULD be replacd with logic in the theme itself, so it knows where it is/ what page it is on. Not the best solution, but a solution.

I would miss it, but I see more value in having the multiple block regions. This has the potential to solve some of th eproblems I was using mutilple theme support for. Instead of calling a new theme to print a NEW region at the bottom of the page (these pages all share the same style sheet btw), I could assign a block to that region and have it turn on on the pages I want.

I have yet to test this patch. I will do that shortly and report any suggestions regarding the UI.

To clarfiy, drop multiple theme support and bring in the multiple block regions.

moshe weitzman’s picture

Dries makes a pretty compelling argument for one active theme at a time.

Furthermore, it occurs to me that the same tricks we do today with $custom_theme will work in the future. In other words, we can still change the active theme on a page by page basis. Thats probably what Nedjo meant by retaining use of multiple styles even in a single theme system.

single theme is ok with me.

moshe weitzman’s picture

Dries makes a pretty compelling argument for one active theme at a time.

Furthermore, it occurs to me that the same tricks we do today with $custom_theme will work in the future. In other words, we can still change the active theme on a page by page basis. Thats probably what Nedjo meant by retaining use of multiple styles even in a single theme system.

single theme is ok with me.

ezheidtmann’s picture

User-selectable themes are useful for theme developers to use their new theme and make sure it works well before making it the site default.

Programmatically selectable themes (in hook_init()) are also very useful. I use it to send out the page in bluemarine if the browser is IE5 and our regular theme (modified friendselectric) otherwsie. Losing this functionality is a Bad Thing (TM).

Kobus’s picture

I personally have only the need for one theme, but multiple style sheets. I am happy with the single-theme approach.

Regards,

Stefan Nagtegaal’s picture

Like Moshe, there are plenty of other manners how you could have multiple themes in drupal. I'am completely confident with a single theme system...

So, +1 for removing it..

Gábor Hojtsy’s picture

Stefan, why push the theme system under another layer, if we can have one layer built on top of it instead. Problem is that limiting the system to one theme, we add another layer of complexity for those, who would like to have multiple themes, while with the current system plus another block arranging layer we can preserve what is already there from the programmer and from the user point of view too.

I imagine something where I can categorize blocks (add terms to them :) and then decide per theme, what term goes to what region. No, I am not about to be able to contribute code at this time, so if noone else picks up the idea, then please discard.

brmjo’s picture

Hello,

I have read all the comments in this post and with the help of my friend I installed the patch in my site. Everything looks fine, the blocks menu show the diferent regions available, etc.
But I have a problem: from a designer point of view, how do i 'insert' or 'supply' the new regions on a custom theme i'm creating? I have the following:

</php print $sidebar_left ?>

and

</php print $sidebar_right ?>

in diferent places of my page.tpl.php, but how do I place, or create the new regions on diferent parts of my template?

Thank you for your help, sorry if there is an obvious solution to this, I'm not a programmer.

Chris Johnson’s picture

Not a crazy idea, at all. I think it's a very good idea!

djnz’s picture

Well I like multiple themes, but I also want more than two regions to put my blocks in, so I don't like the way this is going. Solution? Code it myself as a module - here it is (once the project is set up) http://drupal.org/node/27285 or get it straight from CVS if you can't wait: http://cvs.drupal.org/viewcvs/drupal/contributions/modules/flexiblock/fl...

My aim for doing this was maximum backwards compatibility, and I think I have achieved this. flexinode.module just needs to be uploaded, enabled, and then you can allocate blocks to regions from the single admin screen. Block allocations are stored using set_variable() so there is no database impact.

Of course nothing will happen unless you change your themes, but again I have tried to make this as 'Drupal friendly' as possible (hints are commented in the file).

Comments please?

chx’s picture

To add my two cents: I was against losing multiple themes but moshe is right.

Also, for Goba's comment on using terms for blocks -- why not? I will post a patch to realize http://drupal.org/node/899 soon.

Bèr Kessels’s picture

aargh! No, Nooooo, NO! and no. :) (ber takes a deep breath and counts to ten)

Allright. No. -1 on lossing one of the only real powerfull things in Drupal. As opposed to other big CMSes, that is.

Frankly I don't care abouit the UI of the admin, in this very case, but if we are going to trow away one of the best featurs of Drupal-as-devel-platform, because we cannot get our interfaces right; we are doomed.
Really, this is a UI problem, one of many. Are we going to drop taxonomy, because the UI of it sucks, next? Fix the problem where it occurs,

So, now why I like more themes so much: We don't use half of the power of the multiple themes. mobile themes; print themes; PDF themes, XML themes; XUL themes; RSS themes; admin themes; development themes; user-section themes (my blog is red, yours is yello; whatever themes; taxonomy-term-themes. oh and themes.drupal.org would break, but thats broken anyway :)

Oh, and a long-standing-issue: "enabled" themes are really only "by-user-choosable-themes" Don't get confused by that, in this thread.
In that line, I would like to add, that a one-theme-config-page, as opposed to the per-theme-config we have now gets a +1 from me. Maybe that will solve some of the issues.

adrian’s picture

FileSize
82.23 KB

Ok..

The image attached to this is what I envision the basic drupal interface to look like (without the views module).

I added a new path , 'admin/display'
Notice the default tab says 'theme' and not 'themes'
The 'enable' here means what 'default' used to in the previous screen.
The regions tab is the block screen.
The setting is the theme settings, although a _LOT_ of that needs to change (but that's another problem)

I'll be uploading some mock up shots of the views module.

adrian’s picture

FileSize
110.95 KB

Here is what I mean with my views approach.

1) Notice the user selectable column?
Any view you create will be visible to the user in their profile screen.

2) The path to this is admin/views
Each of the view names is a link that goes to the view configuration page.

3)There will be a 'views' table, that will hold the information for each of the views (normalized and optimized of course).
When you use admin/display , you are actually setting view 0...
The default view will not display here.

4) Each of the views contains :
a ) a theme selection
b ) theme settings
c ) block configuration
d ) a set of rules it must match against
e ) a weight.

5) On system load, the theme system will display the highest view that has a successful match,
else it will fall back on the default. This will actually be fairly fast if done right .. and you'll see
what's cool about this when i post the next pic.

adrian’s picture

FileSize
54.76 KB

This is what each of the individual view edit pages looks like.

It adds the new rules tab, but the other three tabs are taken directly from admin/display.
The functions that save the default view, need to be written using 'callback arguments', so that they will
work with whichever view we are interested in, they just get instantiated for whatever arg(2) { ie: admin/views/X } is.

The design of the form is taken from just about every mail client under the sun, and i figured it is the most flexible solution.

You can decide to match either any, or all of the rules specified.

You use the drop down to add different rule types , which adds a collapsible group with a bunch of paramaters in a form.

I figure that we could probably use some form of templating, and cache the rules as php in the database, so we won't have to
build each of the rulesets on load, but just execute the view's rule cache.

Some possible rule types :

1) Taxonomy :
The page being viewed is either a listing for node type x, or a node of type x.
2) Site Load :
The throttle can be checked for a value above, below, between certain ranges.
This allows for a more transparent way of configuring your different load levels.
3) Date Range :
Current date (or node date) is in a certain date range.
4) User roles :
User has certain permissions assigned to him.
5) Node type :
self explanatory
6) Path :
ie: anything starting with admin/ , or however we wanna do it.
I have some interesting ideas regarding this, but i don't know if i want to go there right now =)
7) URL
If the domain is mobile.mysite.com, use the mobile view.
8) Custom :
The php block we have at the moment for each of the individual blocks.

9) ?????
perhaps code it so that it's a hook that you can add more rules to.

Now, this cuts down on a whole lot of pages. Ideally, i would like to get rid of each of the individual block configuration pages .. and instead
give the user this to view.

Not sure how user level 'show these blocks' settings will interfere with this though, as it's completely view dependent, and views can change.

We could however use this as a spring board for allowing users their own 'cloned view' and allowing them to move their blocks wherever they want them. Especially if you consider this could be used to give the user the ability to have blog specific themes.

ezheidtmann’s picture

Adrian, that looks very, very cool. I love it.

The only thing that's confusing is the "rules" page. Have you considered something like the filter interface on admin/node? I find filtering on admin/node is easy, flexible, and intuitive.

adrian’s picture

I've been looking at the filtering on node, and I don't believe it's flexible enough.

The mock up you saw was a very quick html layout basically.

If you open any modern email client, and look at the filters, you will see exactly what I intend to implement.

nedjo’s picture

FileSize
33.87 KB

Thanks for all the feedback and suggestions a few days back on multiple themes and regioning.

The priorities I heard were:

* maintain multiple theme support
* keep a block overview admin page
* make block placement in different themes easier/more predictable
* if possible, open the way for an AJAX-based interactive regioning solution, e.g., drag blocks to the regions they should be in

I've implemented a solution that, I'm thinking, pretty well meets these priorities. Rather than moving region placement to the individual block configuration page, I've implemented a distinct local task (admin page) for each theme, so that each theme can have its own settings, not only for block placement but also enabling and weight.

To implemement this, I've added a 'theme' field to the blocks table. The trickiest part is ensuring that, when a theme is enabled, a default set of blocks are added (as when, on drupal installation, two blocks from the user module are enabled). I've introduced a system_initialize_theme_blocks() function for this purpose.

I'm hoping that this patch iteration is nearing readiness to apply. Please review and test if you are in a position to do so.

Screenshot to follow.

nedjo’s picture

FileSize
15.89 KB

Screenshot showing theme-specific block admin. There is a local task for each enabled theme. Clicking on the theme's link loads a block admin page rendered in that theme, with that theme's available regions highlighted, and with that theme's available blocks as placement options.

Bèr Kessels’s picture

FileSize
14.15 KB

the patch of update.inc failed. threrefore a renewed patch (another update was committed yesterday.)
Help is only rendered for current active DEFAULT_LOCAL_TASK. But AFAIK that is simply a flaw in our help hook!
I am a it disapointed there is no default header region.
I dislike the fact you do a custom addition of CSS in the HTML. we have plenty of Admin CSS in drupal.css. whether or not that should be there is another discussion. So, for consistancy, I would like to add the CSS in drupal.css and remove the drupal_set_head. But I dared not hack up your module and ideas. Please comment.

I had a hard time grokking the drupal_get conetent and drupal_set content. I wanted to do the following:
* Add drupal_set_content($key, '

' . t('%region region', array('%region' => $value))); to the *top* of each region
* Add drupal_set_content($key, '

') to the *bottom* of each region. Thus wrapping the region in a temprary DIV.
That div can then be highlighted with
That way we could use the CSS (instead of the current CSS):

/**
 * blocks Admin
 */
.regionhighlight .label {
  background-color: #ffff66;
  position:relative;
  top:0;
  left:0;
  padding:0;
  margin:0;  
}
.regionhighlight:hover {
  border: 1px solid #ffff66;
  top: -1px;
  right: -1px;
}

All CSS 2 browsers will show a border around the region when hovered with the mous. Yes, that excludes IE. No, I don't care that they see less. It does not break for IE, it only add functionaliy for non-IE users. Fixing this for IE would mean hacks in CSS, wich is a road I want to avoid at all costs for core!

And last a more general question:
We parse content into message regions etc Should we -in future, this patch is complicated enough as it is- consider running HELP texts trough the blocks. And other content, like footer, mission, hell, maybe even $content! But agoin, its only a question, and shuold not go into this patch, yet. Lets take small steps at the time.

So bottomline:
a big +1 for the patch as it is now!. an even bigger +1 from me when above things were to be implemented.

Bèr Kessels’s picture

FileSize
35.46 KB

>:§ wrong patch!

nedjo’s picture

Thanks for the review.

I am a it disapointed there is no default header region.

I left this out only because I was limiting myself to regions that were already defined as variables in phptemplate. I want to leave this to the theme designers. If you'd like to add it in now, though, please do.

I dislike the fact you do a custom addition of CSS in the HTML. we have plenty of Admin CSS in drupal.css.

Yes, it would be better in drupal.css. And I like your improved CSS.

But I dared not hack up your module and ideas.

Please, hack away and post a new patch.

Should we -in future, this patch is complicated enough as it is- consider running HELP texts trough the blocks. And other content, like footer, mission, hell, maybe even $content!

All possibilities. We could also - again, in future patches - look at migrating some of the existing drupal_set*() and drupal_get*() functions to use drupal_set_content() and drupal_get_content() instead.
If you are rolling a new patch, could you add the following?
Instead of my existing

  return form($output, 'post', url('admin/block/list/' . $theme_key));

please put

  return form($output, 'post', arg(3) ? url('admin/block/list/' . $theme_key) : url('admin/block'));

so that, if it's the default theme, the local local task highlighting will work properly.

killes@www.drop.org’s picture

FileSize
1.48 KB

Dries asked me to review this patch.

I've installed it on a fesh cvs site.

I did not install any custom theme.

Everything works, as far as I can see.

There is just something that I think will confuse users: the yellow margins do not fill out the whole block region. I think that is confusing, especially if you put a block into the footer and then the yellow is still below that block. I think it should be possible to colour the whole region through some css.

There also seems to be a bug: After adding the block to the footer region, I enabled another theme and switched to it. When I visit the block configuration page, the moved block is neither in the "left sidebar" nor in the "disabled" part of the config screen. I think it should be somewhere. :)

logictude’s picture

Title: Enable multiple block regions (not just "left" and "right" sidebars) » Is this simple to do?

I woke up this morning wondering how to accomplish just what this thread is discussing. After reading the entire discussion I thought I would add my two cents. I have a reasonable understanding of the Drupal system and wondered if this couldn't be made a little simpler. With a few more hours in my day I'd give the development a shot. In the meantime I'd like to at least share my thoughts.

* A field is added to each row in the admin/blocks page labeled "Group". [i.e. Assigning blocks to the "foo" group would lump these blocks together in a user-defined region.]
* Any theme that has <?php print $sidebar_foo ?> would render accordingly. This puts the impetus on the theme developer.
* On the admin/blocks page change the "Region" setting to a "Default Region" setting.
* To honor the "Default Region" you would add add an option to admin/themes/settings that would allow admins to affirm "Honor Block Groups/Use Default Block Regions".

This is a pretty rudimentary look at what I think accomplishes the primary goals. I just wanted to throw this out there.

Thoughts?

Steven’s picture

Title: Is this simple to do? » Enable multiple block regions (not just "left" and "right" sidebars)

Restoring bad title edit.

nedjo’s picture

FileSize
34.4 KB

Thanks for the review killes.

There also seems to be a bug: After adding the block to the footer region...

Yes, this was a bug, thanks for finding it. I've gone over the code and made several small changes, fixing this and some related issues. The attached patch also moves highlighting css to drupal.css as per Bèr's suggestion (though I didn't use Bèr's suggested revised code, I didn't follow all of it partly because drupal.org deleted the div tags he'd presumably used).

Yes, it might be nice to highlight the entire region, but this isn't easily accomplished (without hacking up themes). I've changed the highlighting text to be simply the region name, rather than '[region name] region'. My aim is that this gives you an idea of where your block content will appear--not of the whole region (some of which will be prefilled with other content). There is no easy way within the context of this patch to put content at the top of regions and the bottom as well (as Bèr suggested).

Please let me know if anyone finds further issues. Otherwise I'll expect this to be speedily approved or finally rejected. Several months and eleven increasingly complex iterations is feeling like enough to me.

I'll commit to follow up fixes if needed after the patch is applied.

Dries’s picture

FileSize
35.42 KB

I decided to review this patch nonetheless because Gerhard's review lacked some depth (no offense).

I fixed a couple glitches (eg. 2 bugs in phptemplate.engine) and made some minor changes (eg. renamed new CSS to match Drupal's CSS conventions). My version of the patch is attached. In addition, I have some final comments:

1. system_region_list() has $asterix stuff which is no longer needed. Please remove.

2. system_region_list() has $scope, which I don't quite understand. Looking at the code, not all possible values appear to be used. Maybe double-check that code, and document _why_ and _when_ one would want to specify $scope. The use and function of $module_regions does not appear to be documented? Do we need this or is this a left-over? Looks like a left-over to me.

3. Theme marvin does not return any regions.

4. The way regions are defined is a little weird. Can't we make the first region the default region and simplify the code? In fact, system_default_region() could call system_region_list() and return the top-most element. A lot simpler IMO.

5. Because all themes need to specify a default region, return 'left'; seems to be just bloat.

6. Sometimes we use $theme, sometimes we use $theme_key. Can't we settle on $theme?

7. Clicking the theme-subtab switches to the active theme (which is nice). We could consider doing to same for the theme configuration settings.

8. The theme-subtabs work nice but are still confusing. People will think the 'configure' links enclosed withing the tab are theme-specific. At least that is what I thought until I discovered these were still global block settings. It got me confused for a minute or two. I guess it is OK for now.

9. phptemplate exports weird-ish block regions. Like, putting a block in 'help' screws your layout royally. Similarly, there is not much value in having both 'footer' and 'closure', I'd think. It only adds to the confusion IMO. The destinction between footer and closure is more of an artefact than anything else. Similarly, 'messages' and 'help' is not something one should add blocks to IMO. I think it would be much better/easier to create a 'top' region.

10. I think it would be better if the yellow tags appear above the blocks in that region. It's more natural to have titles at the top of listings. If you put blocks in 'help' it is hard to tell whether they belong to 'help' or 'messages'.

I think this patch is ready to be committed after the next update. One more revision and we're done. Promise.

Dries’s picture

Status: Needs review » Needs work

Updating the status. :)

Thanks for your persistence nedjo. We'll commit this patch shortly, and can improve things incrementally after that. Feel free to postpone some suggestions.

drofnar’s picture

Ive read this discussion with interest and just want to those who have worked so diligently to bring this new functionality.

I am not a developer, Im a user, or actually a person wishing to use Drupal to create community site/s, so am not the real END user. I just want to add my small perspective on the multiple theme or not discussion. I am very relived thats not been dropped. My reasoning is as follows:

The reason I was attracted to Drupal is that it seemed to be the closest tool yet to allow the building of a real community (community plumbing is very appropriate). The powerful thing for me was it combined the community CMS with blogs (personal CMS in effect). The blog side for me is not just a small deal its everything, because myself (and others ) believe that Personal Centered Communications (of which blog is an example) are essential to community. We need to empower the individual content management capabilities as much as possible if we want individuals to feel that they really do have their own home on the site rather than just a temporal piece of a larger community. James Surowiecki describes the essential qualities that can generate wisdom in crowds, and important ingredients to bring about this "collective Intelligence" is perhaps surprising, its the independent and distributed nature of participants. I believe that Drupal will dramatically lose its value as community plumbing if it diluted the capability provided to individuals in that community. Multiple themes are but one aspect - and not the most important, but still would represent a loss. If we wanted ultimate end users to feel they really own their place in the community, then how can we deny them the ability to select from at least a limited set of themes. Please dont underestimate the importance of the "personal CMS" aspects that Drupal is providing.

Im not that experienced in Drupal, and this may lead further afield, but the same issue of end user empowerment still needs further consideration, because a blog of a user within a drupal community site is not yet independent enough. A single person using Drupal as the tool for their personal blogsite is great, but a single user trying to create a personal blog of any real individual character within a community is very much constrained.

A possibility to consider if Drupal doesnt want to support the individual blog/theme capability beyond basic, would be to let ultimate end users plug their own blog into an existing community somehow. ie someone who already has his own blog (and theme) built in wordpress, may choose to plug that in somehow, rather than use the standard drupal assigned blog. This removes the burden of competing with personal blog focussed engines, and lets drupal focus on the core community plumbing aspects while still leveraging the best blog tools out there. Drupal already has a blogapi that allows posts created in a differenet tool to find their way into the systme, why not go all the way. Drupal would become an even more powerful community plumbing if it gave still greater importance to individuals personal space. Marc Canter talks of Digital Lifestyle Aggregators proliferating, blogs really being a kind of early element of this but the community plumbing comes from where?. Drupal represents an alternative independent and open source, and hopefully open data, community glue to the Yahoos, googles and Microsofts of the world.

Anyway congrats on the work, Drupal is still the best

djnz’s picture

#119 submitted by logictude on July 31, 2005 - 03:58 updated

* A field is added to each row in the admin/blocks page labeled "Group". [i.e. Assigning blocks to the "foo" group would lump these blocks together in a user-defined region.]
...

I had the same thoughts as you - there is the possibility for a simple improvement to do 90% of what is wanted. And I had the time to do it! Rather than patch existing code and modify tables, I implemented the Flexiblock module - take a look if you are interested.
--------------------- WEBg8 ---------------------

nedjo’s picture

Thanks Dries for the characteristically perceptive review. I'm working on these changes and will post a new patch in the next few days.

Rather than patch existing code and modify tables, I implemented the Flexiblock module - take a look if you are interested.

It's a good idea. Fixing this in core instead as an add-on module has I believe a number of advantages (though clearly it's more complex), but your module should be useful for 4.6 users. And, if and when multiple regions hit core, a regioning module, perhaps based on yours, could provide admin-configurable regions using the (new proposed) hook_regions() hook.

nedjo’s picture

FileSize
32.97 KB

I've substantially rewritten the patch to try to improve efficiency and cut out what's not absolutely needed.

Mainly, I've removed region listing from the system_theme_data()function. It doesn't need to be there anymore, since regions are only loaded for a single theme at a time, and it should be more efficient now (as previously all .theme and .engine files were loaded).

Replies to Dries' comments:

1. system_region_list() has $asterix stuff which is no longer needed. Please remove.

The asterixes are now used for any module-defined regions, so that they are identified on the block admin pages, so I've left that part in.

2. system_region_list() has $scope, which I don't quite understand. Looking at the code, not all possible values appear to be used. Maybe double-check that code, and document _why_ and _when_ one would want to specify $scope.

I've removed the $scope parameter.

The use and function of $module_regions does not appear to be documented? Do we need this or is this a left-over? Looks like a left-over to me.

This is for a new hook, hook_regions(), by which modules can define their own regions, which are then added to the list of available regions to which blocks and other content can be assigned. They are defined in the same way as the themename_regions() calls.

3. Theme marvin does not return any regions.

Fixed. I hadn't properly referenced styles' themes.

4. The way regions are defined is a little weird. Can't we make the first region the default region and simplify the code? In fact, system_default_region() could call system_region_list() and return the top-most element. A lot simpler IMO.

Good suggestion, done.

5. Because all themes need to specify a default region, return 'left'; seems to be just bloat.

Gone.

6. Sometimes we use $theme, sometimes we use $theme_key. Can't we settle on $theme?

Most uses of these global variables are now eliminated. There is a difference, I believe: if the current theme is a style, $theme_key will be that theme, but $theme will be the theme that the style is based on.

7. Clicking the theme-subtab switches to the active theme (which is nice). We could consider doing to same for the theme configuration settings.

Yes.

8. The theme-subtabs work nice but are still confusing. People will think the 'configure' links enclosed withing the tab are theme-specific. At least that is what I thought until I discovered these were still global block settings. It got me confused for a minute or two. I guess it is OK for now.

No change made.

9. phptemplate exports weird-ish block regions. Like, putting a block in 'help' screws your layout royally. Similarly, there is not much value in having both 'footer' and 'closure', I'd think. It only adds to the confusion IMO. The destinction between footer and closure is more of an artefact than anything else. Similarly, 'messages' and 'help' is not something one should add blocks to IMO. I think it would be much better/easier to create a 'top' region.

I've eliminated the help, messages, and closure regions and introduced a 'content top' one as well as a 'header' region (to address Ber's request). Some css work would be useful on the presentation of the header region in bluemarine and pushbutton.

10. I think it would be better if the yellow tags appear above the blocks in that region. It's more natural to have titles at the top of listings. If you put blocks in 'help' it is hard to tell whether they belong to 'help' or 'messages'.

Not readily done without hacking up the themes, so I've left this as is.

nedjo’s picture

FileSize
32.19 KB

Dries:

I looked at it and it looks good. The one thing that confuses me is
the module regions. I'm not sure we should support these at the
moment. I'd remove that for now.

I've removed the proposed hook_regions() to enable modules to define their own regions, along with all related code (e.g., asterixing of module-defined regions). I will introduce this as a subsequent patch.

Also content_top and content_bottom are still somewhat awkward to
me. Any reason 'header' and 'footer' aren't enough?

I've removed the content_top and changed content_bottom back to plain content.

Dries’s picture

The last patch is malformed!

Also, the following query doesn't look right (4 keywords, 5 values):

-    db_query("INSERT INTO {boxes} (title, body, info, format) VALUES  ('%s', '%s', '%s', %d)", $edit['title'], $edit['body'], $edit['info'], $edit['format']);
+    db_query("INSERT INTO {boxes} (title, body, info, format) VALUES  ('%s', '%s', '%s', %d, %d)", $edit['title'], $edit['body'], $edit['info'], $edit['format']);

Lastly, chameleon_regions() still uses the old region-scheme ...

+function chameleon_regions($op = 'list') {
+  switch ($op) {
+    case 'list':
+      return array(
+           'left' => t('left sidebar'),
+           'right' => t('right sidebar')
+      );
+    case 'default':
+      return 'left';
+  }
+}
nedjo’s picture

FileSize
31.55 KB

Oops, here's a fixed patch. I also cleaned up a couple of other loose ends, e.g. improved and updated some of the documentation.

Gábor Hojtsy’s picture

A fresh install of Drupal with bluemarine displays blocks correctly, but when I switch the default theme to pushbutton, all the blocks disappear. They do show up in ?q=admin/block, but just with the yellow helper boxes, no blocks are really displayed.

Thox’s picture

Same problem as Goba.

The "region" field in the blocks table is sometimes blank. This makes many themes almost unusable in a Drupal default install. I don't know how the fields are blank, but the following SQL helped me get back to theme development:

UPDATE blocks SET region="left" WHERE region=""

Bèr Kessels’s picture

another confirmation. I found out about the exact same sql query as Thox to fix it:)
We came across this in an update. The theme had the regions defined, but since it was a non-default theme the blocks dissapeared. A drupal site, without a navigation block is simply useless.

nedjo’s picture

Thanks for noting this problem. I'm moving this to a new issue at http://drupal.org/node/29506 --easier to find, and also this issue is so long it won't mail out.

nedjo’s picture

Status: Needs work » Fixed
Anonymous’s picture

Anonymous’s picture

Status: Fixed » Closed (fixed)
Dave Cohen’s picture

Version: » 4.6.3

As a user who's pretty familar with drupal 4.6, and only recently using drupal from CVS, I want to share my experience.

I installed drupal-cvs and found the familiar bluemarine theme working pretty much as expected. I copied a theme from one of my 4.6 installs into the new install, enabled it, and under 'my account' I chose it as my theme. (If it worked, I would make it the default). It mostly worked, but no blocks showed up. Specifically Navigation did not show up, which makes any further configuration rather difficult. I never went to admin/block using my new theme because the navigation link was never there. I assumed there was some code change making the blocks not show up.

After poring over some code and not seeing why the blocks did not appear, I resorted to copying bluemarine to a new name, and enabling that theme (an exact copy of bluemarine). Again, no blocks appeared. That's when I did some queries on drupal.org and eventually found this thread. So now it makes sense to me. But my experience was pretty frustrating. I wonder if there are ways to make this process clearer to people. For starters, I would change the message "The blocks have been saved" to "The blocks have been saved for theme bluemarine" Anything to draw attention to the fact that settings only apply to the theme currently being used.

Also, I think it will be frustrating when adding new blocks to remember they must be added to all themes. I suggest adding "all themes" to the list of theme tabs shown on admin/block, and any changes made there apply to all themes. This would be useful for the Navigation block in particular. In the database the blocks.theme column could be left null or '*' in this case.