The function devel_node_access_block_view() calls theme_form_element() three times, instead of theme('form_element').

Additionally, it is preferable to build renderable arrays, than to generate HTML by calling theme functions when generating content for hook_block_view(), but I understand this is ported over from Drupal 6 and people aren't used to the new method yet. I still do this myself.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

danielb’s picture

Though each use of theme_form_element in this function is simply used to output one sentence of text in a 'description' container.

salvis’s picture

Please post a patch.

danielb’s picture

cvs update -dP -r DRUPAL-7--1 removes all the files from the project :/
I will try to patch against the downloaded release.

edit: nevermind, found it in Head

danielb’s picture

Here's my patch. I dunno, it's not perfect, there are still theme function being called to compose the tables and lists, but I don't know if passing arrays in to those would work.

You should probably review this thoroughly as I'm still new to Drupal 7. I'm unsure about the use of '#prefix' and '#suffix' for wrapper divs.

I've also attached a much simpler patch for 6.x.

There are likely other places in this project where improvements could be made to the building of output in D7.

salvis’s picture

Status: Active » Needs work

The D6 version had an extraneous parenthesis. Fixed and committed. Thanks!

For D7 I agree that returning renderable arrays is preferable.

The use of '#prefix' and '#postfix' is uneven in core, but if we go for renderable arrays, then it's logical to also go for '#prefix' and '#postfix' wherever possible, because the idea is the same. Please do this and then set the status to 'needs review'.

Otherwise the patch looks good.

danielb’s picture

The use of '#prefix' and '#postfix' is uneven in core, but if we go for renderable arrays, then it's logical to also go for '#prefix' and '#postfix' wherever possible, because the idea is the same. Please do this and then set the status to 'needs review'.

I don't understand what you're saying, and whether you've said '#postfix' instead of '#suffix' by accident? I've already used #prefix and #suffix in a few places where there was need for a wrapper around something to be themed. It isn't used in places where there is already a block of #markup, I don't see the need.

salvis’s picture

Yes, I meant '#suffix'...

The reason for returning renderable arrays is to make it easier for other modules to get to the content of what you're returning and possibly to change it, without having to resort to regexes to analyze the HTML. If we accept this as a valid concern, then we put enclosing <div>s into '#prefix' and '#suffix', too, to make it easier for other modules to get to the content of what we're returning.

danielb’s picture

Status: Needs work » Needs review
FileSize
9.55 KB

Good point here's an updated version. I'm actually uncertain about how to view the output for some of these (like the bit where I added the variable $account_items) so consider this needs a review.

salvis’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

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