User login

Drupal 7

Undo Drupal's over-aggressive shortening of user names

And use a real ellipses!

Drupal's theme_username() is used many places within Drupal, and shortens any name over 20 characters, which can be a lot if you encourage people to use full names. This can be undone with a preprocess function in your module or theme, just replace EXAMPLE with your module or theme name.

Have menu local tasks (view, edit, etc. tabs) show menu item description as tooltip

Most menu items in Drupal 7 show a link tool-tip, or title, but local tasks (the tabs you are most used to seeing as the edit link tab on full node pages sadly do not follow this sensible pattern.

Until Drupal core is fixed so that menu item "description" is applied to title attribute of menu tab links", here is a fix for Drupal 7. Change this to your custom theme's name (replace 'example') and drop into your theme's template.php file:

Beware of transactions in Drupal 7

Drupal 7's database layer makes use of transactions in several places. Be careful when you expect to see the results of node_save() outside of the scope of the current request. If someone accesses your website data before the transaction has been committed, the results of queries executed within are not visible. Either all queries succeed or nothing happens at all in a database transactions.

Wrapping a link around a renderable array for images in Drupal 7

I was asked a question about theming linked images and gave the wrong answer, that it was a known pain point, but it kept bugging me because i was pretty sure i was not remembering something. The failure of link render arrays i was thinking of is their use in item_list, but in fact there is a secret theme function that can be used to put linked images in a render array properly.

Thanks to the amazing Morbus Iff for documenting using theme_image_formatter in a render array:

Best practice for an upgraded site to define RDF mappings for RDFa output?

A site that has been upgraded from Drupal 6 to Drupal 7 has not even had this code from standard.install in the Standard profile run yet. Can generic mappings like this be easily taken care of in other custom configuration of RDF or should this (plus more?) go in an update hook?

Preprocess from a module: removing the content author from Drupal 7 search results

All, not just most, but all the content on a particular site was set to be posted without showing the by-line or submitted by text. Given this requirement, it makes no sense to have search results show the user that submitted the content, every time. This can be themed away in search-result.tpl.php or it can be removed with a pre-process function as shown below.

You can do this from a module or a theme, where 'example' is the system name of that module or theme:

Syndicate content