[development] Table hook idea

FGM fgm at osinet.fr
Thu Nov 8 08:23:08 UTC 2007


>From seeing the existing answers, it looks like a good idea, notably
considering the current limitations of theme_table (no
thead/tbody/col/colgroup).

However, if you think of it a bit more, what's so special about a table ?
Why not use a generic renderer alter instead ? That way any XHTML element
being rendered could be altered instead of having this one specific element
being singled out, and probably other elements in future iterations of
drupal ?

This is something fairly obvious with PHP5 magic methods: a generic renderer
could be invoked using the name of element to output as a static method, and
the __call implementation could fire hooks on elements for which alters have
been registered.

(FWIW, I'm mentioning this because a non-drupal XHTML module I have written
works exactly that way: the XHTML renderer takes methods with ($element,
$attributes = null, /* and other less useful optional params */) and checks
them for validity under the XHTML DTD, preventing the creation of invalid
pages.


----- Original Message ----- 
From: "Mike Cantelon" <m_cantelon at straight.com>
To: <development at drupal.org>
Sent: Wednesday, November 07, 2007 8:59 PM
Subject: [development] Table hook idea


> Is there any interest in adding hook support to table rows and cells to
> allow on-the-fly modification of table data by modules? Something like
> "table_alter($headers, $rows)" and/or "row_alter" and "cell_alter".
> Seems to me this would be easy to do by adding support for an "id" key
> for tables, rows, and/or cells so if the id is set the hook is invoked
> in other modules.
>
> Cheers,
> Mike
>
>
>



More information about the development mailing list