type;
}
}
/**
* Generate item lists of terms per vocabulary. To be executed from
* preprocess_node.
*
* @param $vars
*/
function mytheme_terms_by_vocab(&$vars) {
if($vars['terms'] && $vars['page']) {
$vars['terms'] = '';
foreach($vars['node']->taxonomy as $term) {
$taxonomy[$term->vid][] = l($term->name, 'taxonomy/term/'.$term->tid);
}
foreach($taxonomy as $vid => $terms) {
$vocab = taxonomy_vocabulary_load($vid);
$vars['terms'] .= theme('item_list', $terms, check_plain($vocab->name));
}
}
elseif($vars['teaser']) {
$vars['terms'] = '';
}
}
/**
* Add a "date block" to the beginning of the content. To be executed from
* preprocess_node.
*
* @param $vars
*/
function mytheme_add_date_block(&$vars) {
$day = format_date($vars['created'], 'custom', 'j');
$month = format_date($vars['created'], 'custom', 'M');
$year = format_date($vars['created'], 'custom', 'Y');
$date_block = '
';
$date_block .= '' . $month . '';
$date_block .= '' . $day . '';
$date_block .= '' . $year . '';
$date_block .= '
';
$vars['content'] = $date_block . $vars['content'];
}
/**
* Display only the author, not the date submitted. To be executed from
* preprocess_node.
*
* @param $vars
*/
function mytheme_display_only_submitted_author(&$vars) {
if($vars['submitted']) {
$author = user_load($vars['uid']);
$vars['submitted'] = t('Submitted by:') . ' ' . l($author->name, 'user/'.$author->uid);
}
}
/**
* Add attributes to the node object. To be executed from preprocess_node.
*
* This provides a new variable ($attributes) to be added to the node wrapper
* div. This variable contains the attributes (classes and ID) needed.
*
* @param $vars
*/
function mytheme_add_attributes(&$vars) {
/**
* id="node-nid; ?>"
* class="node post clear-block"
*/
$attributes['class'] = 'node';
$attributes['class'] .= ' clear-block';
$attributes['class'] .= ' post';
if($vars['sticky']) {
$attributes['class'] .= ' sticky';
}
if(!$vars['status']) {
$attributes['class'] .= ' node-unpublished';
}
$attributes['id'] = 'node-' . $vars['nid'];
// Add a class for each term on the node, but not in the teaser display.
if($vars['node']->taxonomy && !$vars['teaser']) {
foreach($vars['node']->taxonomy as $tid => $term) {
$attributes['class'] .= ' ' . check_plain(drupal_strtolower($term->name));
}
}
$vars['attributes'] = ' ' . drupal_attributes($attributes);
}