Možno ste sa stretli s problémom pri implementácii hook_user, konkrétne option "view". Tento hook možno vo svojom module použiť, ak potrebujete vypísať nejaké vami dodefinované informácie o užívateľovi (štandardne na stránke /user/1, /user/2...). Problém je často v tom ako a kde zadefinovať tento dodatočný obsah.
V manuály verzie Drupal 6.x sa okrem iného dočítate:
hook_user($op, &$edit, &$account, $category = NULL)
&$account The user object on which the operation is being performed.
$op What kind of action is being performed.
Possible values (in alphabetical order):
* "view": The user's account information is being displayed.
The module should format its custom additions for display,
and add them to the $account->content array.
Return value
This varies depending on the operation.
* "view": None.
Tu úplne nie je jasné akým spôsobom má byť zostavené pole v ktorom sú potrebné informácie prenášané. Uvediem preto príklad implementácie tejto časti hooku _user :
// zaciatok
function example_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'view':
$account->content['example'] = array(
'#type' => 'user_profile_category',
'#title' => t('Example category title'),
);
$account->content['example']['item'] = array(
'#type' => 'user_profile_item',
'#title' => t('Example item title'),
'#value' => 'item text',
);
break;
default:
break;
}
}
// koniec
Komentáre
Poslať nový komentár