The normal look of the user block was too big for my site, and the count of online users was not deemed important enough. Thus here is a patch that makes the display of the user count optional, leaving only the list of online users.

Comments

moshe weitzman’s picture

Status: Needs review » Needs work

id prefer that this be hidden using theme's CSS. if you need a div added to the markup, then submit another patch

Uwe Hermann’s picture

+1 for the idea. I wouldn't force users to manually fiddle with CSS files here. IMHO a config option is the better solution.

killes@www.drop.org’s picture

I think the right answer is not yet another rarely used option, but to make the block's output themable.

Tobias Maier’s picture

I think killes idea is the best :)

Tobias Maier’s picture

Title: Make user count in user block optional » Make (some) user block themeable
Version: 4.6.3 » x.y.z
Assigned: Unassigned » Tobias Maier
Status: Needs work » Needs review

Here is a patch which makes the following blocks themeable:
- User login
- Who's online

I hope you like it

Tobias Maier’s picture

StatusFileSize
new5.27 KB

forgot the patch...

Tobias Maier’s picture

Title: Make (some) user block themeable » Make (some) user blocks themeable

*grrr*

Tobias Maier’s picture

Title: Make (some) user blocks themeable » Make user blocks themeable
StatusFileSize
new6.77 KB

here is a new version of the patch.

all blocks are themeable now.

please review it and tell me if it is ok.

cu tobias

Tobias Maier’s picture

StatusFileSize
new6.75 KB

I changed one line...

Bèr Kessels’s picture

+1. Until the dat ewe run any block trough a theme function by default, this is a great addition. So far I managed to tweak the login block woth locales and CSS, btu this would really help a lot.
Especially now that we have multiple regions, blocks will want to appear different.

It also cleans up some 'ugly' coding (huge functions). by moving the code into smaller functions.

jose reyero’s picture

I dont think themeing individual blocks is a good solution. I'd rather have an ad hock module for providing specific alternate blocks or use CSS for now.

And I'd like to point out that blocks are nearly themeable. I mean we have the theme_block function, which provides separated 'module', 'delta', 'title' and 'content' parameters. The only big problem is that content is plain HTML, very difficult to deal with if you want specific parts remoded.

So, my proposed solution would be to have that $block->content become an array, with named keys. I.e.

$block->content['user list'], $block->content['user count'], etc...

Then, any theme_block function that wants to deal with specific blocks can handle individual elements. And in any other case -which should be the default-, we just do

$output .= is_array($block->content) ? implode('', $block->content) : $block->content;

Then you can start proposing additional patches to split specific blocks' content in elements. But old blocks would still work!!

Hey, this is nearly a patch :-)

adrian’s picture

Eh. I know this is probably not practical to think about right now .. but the form api is not all that form specific. It's just a way to drive the theme system using arrays. All it needs to operate is to turn the theme functions to use an associative array as their only parameter, then you can use them in an array with the same format.

One of the features of the form api, through it's definition of unique id's, is that you can have a theme function for every 'object'.

Tobias Maier’s picture

sorry,

but I dont like your solution.

  • Why introducing a new behaviour how we theme things?
    we theme everything the way how I did it in the Patch.
  • I dont think themeing individual blocks is a good solution.

    I thinkit is very good. think about themes who have for example a login-form on the top? or in the line of the main navigation?
    also the legoscia, the user who started this issue, wanted to change some parts in the default way how the Who's online block looks like.

greets

jose reyero’s picture

StatusFileSize
new4.33 KB

Well, in the meanwhile, I already have the patch.

The only idea behind is going for a general solution instead of thinking of blocks one at a time.

You'll notice that whith this patch you can actually theme that 'who's online' block. And, while simple, it introduces a more powerful mechanism to theme other blocks, and anyway not breaking compatibility with modules -maybe only with some contrib themes.

So I'll just leave the patch here, just take it or leave it, no bad feelings, just hope it's some help. Anyway I came here only because of the patch bingo ;-)

Bèr Kessels’s picture

One of the features of the form api, through it's definition of unique
id's, is that you can have a theme function for every 'object'.

Which is kinda what I had in mind; Similar to the way we cab theme any flexinode field or any flexinode type.

aaron’s picture

+1 to Jose's idea. This would be a good approach for several other blocks as well, where you might want to customize just one bit of it. You could then tap into block.tpl.php to take care of it. I haven't tested it, so I'm not sure if it's current with 4.7. But I need to retheme the who's online block, so I'll probably apply this patch and see how it works.

aaron’s picture

Status: Needs review » Needs work

works well. the patch is out of date, however (rejects user.module's second chunk), and also needs to patch themes/engines/phptemplate/block.tpl.php.

catch’s picture

Version: x.y.z » 6.x-dev
Status: Needs work » Fixed

This is possible now.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.