This very simple change adds two buddylist specific theme functions to allow a user to easily change the contents of table rendered on the buddylisting_page (?q=buddylist). The listing remains a table but these two hooks allow you to change the contents of the table header and to theme each row (1 row per buddy account) to your liking. The default theme functions result in a table that is identical to the current table output of 1.0.

The two theme functions are:

// Theme the header for the buddylisting table - must return an array of column header values - return array() if you don't want any header
function theme_buddylist_buddylisting_header() {
  return array(t('@buddy', buddylist_translation()), t('online'));
}

// Return the theme row for the buddylisting table - $account is the information of the current buddy being themed, $online is TRUE if the $account is currently online
// Must return an array of theme contents for each column specified for the table
function theme_buddylist_buddylisting_row($account, $online) {
  return array(theme('username', $account), theme('buddylist_online', $online));
}

Eventually, it would be nice to not be hardcoded to display as a table but for now, this small baby step provides a lot more external flexibility.

Comments

dldege’s picture

StatusFileSize
new1.71 KB

Here is the patch

robertdouglass’s picture

I don't understand the usefulness of this patch. Everything you're sticking into the new theme functions is either translatable or themable already. Please explain. Also, theme functions generally return HTML, not PHP constructs. These new functions return arrays.

dldege’s picture

StatusFileSize
new2.39 KB

You couldn't really remove or add table columns so this was a quick way to allow that.

Per our conversation in IRC I have changed the approach to provide an overall theme function for the buddylist_page that lets you completely alter the output as needed. The table view is the default output.

dldege’s picture

Title: A theme hooks to buddylist_buddylisting_page » Add theme hooks to buddylist_buddylisting_page
dldege’s picture

Status: Needs review » Fixed

Reworked patch slightly to not load the user record. This can be loaded in the theme handler if the user account record is needed. Commit to DRUPAL-5 branch.

Anonymous’s picture

Status: Fixed » Closed (fixed)