/** * Process variables for comment.tpl.php. * * @see comment.tpl.php */ function unikue_preprocess_comment(&$variables) { $comment = $variables['elements']['#comment']; $node = $variables['elements']['#node']; $variables['comment'] = $comment; $variables['node'] = $node; $variables['author'] = theme('username', array('account' => $comment)); $variables['created'] = date('d F Y', $comment->created); // Avoid calling format_date() twice on the same timestamp. if ($comment->changed == $comment->created) { $variables['changed'] = $variables['created']; } else { $variables['changed'] = format_date($comment->changed); } $variables['new'] = !empty($comment->new) ? t('new') : ''; $variables['picture'] = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', array('account' => $comment)) : ''; $variables['signature'] = $comment->signature; $uri = entity_uri('comment', $comment); $uri['options'] += array('attributes' => array('class' => 'permalink', 'rel' => 'bookmark')); $variables['title'] = l($comment->subject, $uri['path'], $uri['options']); $variables['permalink'] = l(t('Permalink'), $uri['path'], $uri['options']); $variables['submitted'] = t('!username on !datetime', array('!username' => $variables['author'], '!datetime' => date('d/m/Y', $comment->created))); // Preprocess fields. field_attach_preprocess('comment', $comment, $variables['elements'], $variables); // Helpful $content variable for templates. foreach (element_children($variables['elements']) as $key) { $variables['content'][$key] = $variables['elements'][$key]; } // Set status to a string representation of comment->status. if (isset($comment->in_preview)) { $variables['status'] = 'comment-preview'; } else { $variables['status'] = $comment->status == COMMENT_NOT_PUBLISHED ? 'comment-unpublished' : 'comment-published'; } // Gather comment classes. // 'comment-published' class is not needed, it is either 'comment-preview' or // 'comment-unpublished'. if ($variables['status'] != 'comment-published') { $variables['classes_array'][] = $variables['status']; } if ($variables['new']) { $variables['classes_array'][] = 'comment-new'; } if (!$comment->uid) { $variables['classes_array'][] = 'comment-by-anonymous'; } else { if ($comment->uid == $variables['node']->uid) { $variables['classes_array'][] = 'comment-by-node-author'; } if ($comment->uid == $variables['user']->uid) { $variables['classes_array'][] = 'comment-by-viewer'; } } foreach ($variables['content']['links']['comment']['#links'] as $key => $value) { $variables['content']['links']['comment']['#links'][$key]['attributes']['class'] = array('button button-small'); } }
/** * Process variables for user-profile.tpl.php. * * @param array $variables * An associative array containing: * - elements: An associative array containing the user information and any * fields attached to the user. Properties used: * - #account: The user account of the profile being viewed. * * @see user-profile.tpl.php */ function alpha_preprocess_user_profile(&$variables) { $account = $variables['elements']['#account']; if ($account->data['contact']) { // Add contact form link. } foreach (element_children($variables['elements']) as $key) { if (isset($variables['elements'][$key]['#type']) && $variables['elements'][$key]['#type'] == 'user_profile_category') { foreach ($variables['elements'][$key] as $item_key => $item_value) { if (is_array($item_value) && isset($item_value['#type']) && $item_value['#type'] == 'user_profile_item') { if (empty($item_value['#title'])) { $variables['elements'][$key][$item_key]['#title'] = $variables['elements'][$key]['#title']; // We add title only for first item in the group. break; } } } } $variables['user_profile'][$key] = $variables['elements'][$key]; } // Preprocess fields. field_attach_preprocess('user', $account, $variables['elements'], $variables); $variables['name'] = $account->name; $variables['realname'] = isset($account->realname) ? $account->realname : ''; if ($account->signature) { $variables['signature'] = check_markup($account->signature, $account->signature_format, '', TRUE); } module_load_include('inc', 'blog', 'blog.pages'); $variables['blog'] = blog_page_user($account); // print_r($variables); }
/** * Implements template_preprocess_user_profile(). */ function loop_preprocess_user_profile(&$variables) { $account = $variables['elements']['#account']; $variables['full_name'] = _loop_fetch_full_name($account); $variables['loop_user_best_answers'] = module_invoke('loop_user', 'block_view', 'loop_user_best_answers'); // Helpful $user_profile variable for templates. foreach (element_children($variables['elements']) as $key) { $variables['user_profile'][$key] = $variables['elements'][$key]; } // Preprocess fields. field_attach_preprocess('user', $account, $variables['elements'], $variables); }
function magnetto_preprocess_node(&$variables) { $variables['view_mode'] = $variables['elements']['#view_mode']; // Provide a distinct $teaser boolean. $variables['teaser'] = $variables['view_mode'] == 'teaser'; $variables['node'] = $variables['elements']['#node']; $node = $variables['node']; $variables['date'] = format_date($node->created); $variables['name'] = theme('username', array('account' => $node)); $uri = entity_uri('node', $node); $variables['node_url'] = url($uri['path'], $uri['options']); $variables['title'] = check_plain($node->title); $variables['page'] = $variables['view_mode'] == 'full' && node_is_page($node); // Flatten the node object's member fields. $variables = array_merge((array) $node, $variables); // Helpful $content variable for templates. $variables += array('content' => array()); foreach (element_children($variables['elements']) as $key) { $variables['content'][$key] = $variables['elements'][$key]; } // Make the field variables available with the appropriate language. field_attach_preprocess('node', $node, $variables['content'], $variables); // Display post information only on certain node types. if (variable_get('node_submitted_' . $node->type, TRUE)) { $variables['display_submitted'] = TRUE; $submitted = $variables['date']; if (!empty($variables['view_mode']) && $variables['view_mode'] !== 'teaser') { $submitted .= '<span class="info_separator">/</span>'; $submitted .= '<span class="author">' . t('Posted by') . ' ' . $variables['name'] . ' </span>'; } if (!empty($node->comment_count)) { $submitted .= '<span class="info_separator">/</span>'; $submitted .= $node->comment_count . ' ' . t('Comments'); } $variables['submitted'] = $submitted; //t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date'])); $variables['user_picture'] = theme_get_setting('toggle_node_user_picture') ? theme('user_picture', array('account' => $node)) : ''; } else { $variables['display_submitted'] = FALSE; $variables['submitted'] = ''; $variables['user_picture'] = ''; } // Gather node classes. $variables['classes_array'][] = drupal_html_class('node-' . $node->type); if ($variables['promote']) { $variables['classes_array'][] = 'node-promoted'; } if ($variables['sticky']) { $variables['classes_array'][] = 'node-sticky'; } if (!$variables['status']) { $variables['classes_array'][] = 'node-unpublished'; } if ($variables['teaser']) { $variables['classes_array'][] = 'node-teaser'; } if (isset($variables['preview'])) { $variables['classes_array'][] = 'node-preview'; } // Clean up name so there are no underscores. $variables['theme_hook_suggestions'][] = 'node__' . $node->type; $variables['theme_hook_suggestions'][] = 'node__' . $node->nid; // Add css class "node--NODETYPE--VIEWMODE" to nodes $variables['classes_array'][] = 'node--' . $variables['type'] . '--' . $variables['view_mode']; // Make "node--NODETYPE--VIEWMODE.tpl.php" templates available for nodes $variables['theme_hook_suggestions'][] = 'node__' . $variables['type'] . '__' . $variables['view_mode']; }
function casabienestar_preprocess_user_profile(&$variables) { $account = $variables['elements']['#account']; // Helpful $user_profile variable for casabienestars. foreach (element_children($variables['elements']) as $key) { $variables['user_profile'][$key] = $variables['elements'][$key]; } //Add mail to $user_profile variable $variables['user_profile']['mail'] = $account->mail; // Preprocess fields. // Preprocess fields. field_attach_preprocess('user', $account, $variables['elements'], $variables); }
function anchor_preprocess_node(&$variables) { $variables['view_mode'] = $variables['elements']['#view_mode']; // Provide a distinct $teaser boolean. $variables['teaser'] = $variables['view_mode'] == 'teaser'; $variables['node'] = $variables['elements']['#node']; $node = $variables['node']; $variables['date'] = format_date($node->created); $variables['name'] = theme('username', array('account' => $node)); $uri = entity_uri('node', $node); $variables['node_url'] = url($uri['path'], $uri['options']); $variables['title'] = check_plain($node->title); $variables['page'] = $variables['view_mode'] == 'full' && node_is_page($node); // Flatten the node object's member fields. $variables = array_merge((array) $node, $variables); // Helpful $content variable for templates. $variables += array('content' => array()); foreach (element_children($variables['elements']) as $key) { $variables['content'][$key] = $variables['elements'][$key]; } // Make the field variables available with the appropriate language. field_attach_preprocess('node', $node, $variables['content'], $variables); // Display post information only on certain node types. if (variable_get('node_submitted_' . $node->type, TRUE)) { $variables['display_submitted'] = TRUE; $variables['submitted'] = t('!datetime', array('!username' => $variables['name'], '!datetime' => $variables['date'])); $variables['user_picture'] = theme_get_setting('toggle_node_user_picture') ? theme('user_picture', array('account' => $node)) : ''; } else { $variables['display_submitted'] = FALSE; $variables['submitted'] = ''; $variables['user_picture'] = ''; } // Gather node classes. $variables['classes_array'][] = drupal_html_class('node-' . $node->type); if ($variables['promote']) { $variables['classes_array'][] = 'node-promoted'; } if ($variables['sticky']) { $variables['classes_array'][] = 'node-sticky'; } if (!$variables['status']) { $variables['classes_array'][] = 'node-unpublished'; } if ($variables['teaser']) { $variables['classes_array'][] = 'node-teaser'; } if (isset($variables['preview'])) { $variables['classes_array'][] = 'node-preview'; } // Clean up name so there are no underscores. $variables['theme_hook_suggestions'][] = 'node__' . $node->type; $variables['theme_hook_suggestions'][] = 'node__' . $node->nid; }
function visia_preprocess_node(&$variables) { $variables['view_mode'] = $variables['elements']['#view_mode']; // Provide a distinct $teaser boolean. $variables['teaser'] = $variables['view_mode'] == 'teaser'; $variables['node'] = $variables['elements']['#node']; $node = $variables['node']; $variables['date'] = format_date($node->created); $variables['name'] = theme('username', array('account' => $node)); $uri = entity_uri('node', $node); $variables['node_url'] = url($uri['path'], $uri['options']); $variables['title'] = check_plain($node->title); $variables['page'] = $variables['view_mode'] == 'full' && node_is_page($node); // Flatten the node object's member fields. $variables = array_merge((array) $node, $variables); // Helpful $content variable for templates. $variables += array('content' => array()); foreach (element_children($variables['elements']) as $key) { $variables['content'][$key] = $variables['elements'][$key]; } // Make the field variables available with the appropriate language. field_attach_preprocess('node', $node, $variables['content'], $variables); // Display post information only on certain node types. if (variable_get('node_submitted_' . $node->type, TRUE)) { $variables['display_submitted'] = TRUE; $submitted = '<h6>' . t('Posted by !username', array('!username' => $variables['name'])) . ' ' . visia_format_comma_field('field_tags', $node) . '</h6>'; $variables['submitted'] = $submitted; //t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date'])); $variables['user_picture'] = theme_get_setting('toggle_node_user_picture') ? theme('user_picture', array('account' => $node)) : ''; } else { $variables['display_submitted'] = FALSE; $variables['submitted'] = ''; $variables['user_picture'] = ''; } // Gather node classes. $variables['classes_array'][] = drupal_html_class('node-' . $node->type); if ($variables['promote']) { $variables['classes_array'][] = 'node-promoted'; } if ($variables['sticky']) { $variables['classes_array'][] = 'node-sticky'; } if (!$variables['status']) { $variables['classes_array'][] = 'node-unpublished'; } if ($variables['teaser']) { $variables['classes_array'][] = 'node-teaser'; } if (isset($variables['preview'])) { $variables['classes_array'][] = 'node-preview'; } // Clean up name so there are no underscores. $variables['theme_hook_suggestions'][] = 'node__' . $node->type; $variables['theme_hook_suggestions'][] = 'node__' . $node->nid; // Preprocess the Contact form block. $module = 'block'; $delta = 3; if ($vars['block']->module == $module && $vars['block']->delta == $delta) { module_load_include('inc', 'contact', 'contact.pages'); $contact_form = drupal_get_form('contact_site_form'); // Manually prepare status messages. $contact_form['#prefix'] = theme('status_messages'); $vars['content'] = render($contact_form); } }