Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. function ccom_page_alter(&$page) {
  2. if (array_key_exists('#account',$page['content']['system_main'])) {
  3. $account = $page['content']['system_main']['#account'];
  4.  
  5. if (isset($account)) {
  6. drupal_set_title($account->field_complete_name['und'][0]['safe_value']);
  7. }
  8. }
  9. }
  10.  
  11. function ccom_preprocess_user_profile(&$variables) {
  12. drupal_set_title($variables['elements']['#account']->field_complete_name[LANGUAGE_NONE][0]['safe_value']);
  13. }
  14.  
  15. function ccom_preprocess(&$variables, $hook) {
  16. dpm($hook);
  17. }
  18.  
  19. function ccom_preprocess_user_profile(&$variables) {
  20. dpm($variables);
  21. drupal_set_title('mytitle');
  22. }
  23.  
  24. function ccom_preprocess_page(&$variables) {
  25. dpm($variables);
  26. drupal_set_title('mytitle');
  27. }
  28.  
  29. function YOUR_MODULE_menu_alter(&$items) {
  30. // Change the title of user profile pages to the user's name. Gak.
  31. $items['user/%user']['title callback'] = 'YOUR_MODULE_user_page_title';
  32. }
  33.  
  34. function YOUR_MODULE_user_page_title() {
  35. if (arg(0) == 'user') {
  36. // Load uid from url
  37. $user = user_load(arg(1));
  38. // Get the full user name somehow; here, I'm calling a function of my own.
  39. $output = get_user_full_name($user);
  40. }
  41. // Fallback to username if no fields are present
  42. if (empty($output)) {
  43. $output = $user->name;
  44. }
  45. return $output;
  46. }
  47.  
  48. function hook_username_alter(&$name, $account) {
  49. if (arg(0) == 'user' && is_numeric(arg(1))) {
  50. if (isset($account->uid)) {
  51. $name = $account->your_field_name['und'][0]['safe_value'];
  52. }
  53. }
  54. }
  55.  
  56. function mymodule_user_view($account, $view_mode, $langcode) {
  57. if ($account->uid == 1 && $view_mode == 'full') {
  58. drupal_set_title('my custom title');
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement