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
Comment #1
dldege commentedHere is the patch
Comment #2
robertdouglass commentedI 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.
Comment #3
dldege commentedYou 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.
Comment #4
dldege commentedComment #5
dldege commentedReworked 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.
Comment #6
(not verified) commented