Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ccom_page_alter(&$page) {
- if (array_key_exists('#account',$page['content']['system_main'])) {
- $account = $page['content']['system_main']['#account'];
- if (isset($account)) {
- drupal_set_title($account->field_complete_name['und'][0]['safe_value']);
- }
- }
- }
- function ccom_preprocess_user_profile(&$variables) {
- drupal_set_title($variables['elements']['#account']->field_complete_name[LANGUAGE_NONE][0]['safe_value']);
- }
- function ccom_preprocess(&$variables, $hook) {
- dpm($hook);
- }
- function ccom_preprocess_user_profile(&$variables) {
- dpm($variables);
- drupal_set_title('mytitle');
- }
- function ccom_preprocess_page(&$variables) {
- dpm($variables);
- drupal_set_title('mytitle');
- }
- function YOUR_MODULE_menu_alter(&$items) {
- // Change the title of user profile pages to the user's name. Gak.
- $items['user/%user']['title callback'] = 'YOUR_MODULE_user_page_title';
- }
- function YOUR_MODULE_user_page_title() {
- if (arg(0) == 'user') {
- // Load uid from url
- $user = user_load(arg(1));
- // Get the full user name somehow; here, I'm calling a function of my own.
- $output = get_user_full_name($user);
- }
- // Fallback to username if no fields are present
- if (empty($output)) {
- $output = $user->name;
- }
- return $output;
- }
- function hook_username_alter(&$name, $account) {
- if (arg(0) == 'user' && is_numeric(arg(1))) {
- if (isset($account->uid)) {
- $name = $account->your_field_name['und'][0]['safe_value'];
- }
- }
- }
- function mymodule_user_view($account, $view_mode, $langcode) {
- if ($account->uid == 1 && $view_mode == 'full') {
- drupal_set_title('my custom title');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement