Publication Date Update: modulo per Drupal 7 per aggiungere la data dell'ultimo aggiornamento ad un nodo

Publication Date Update è un semplice modulo per Drupal 7 che aggiunge la data dell'ultimo aggiornamento ad un nodo, per essere installato esso necessita del modulo Publication Date, perché esso lavora con la variabile published_at.

Publication Date Update è semplicemente questa funzione:

function publication_date_update_preprocess_node(&$vars) {

  $time_unit = 86400; // number of seconds in 1 day => 24 hours * 60 minutes * 60 seconds
  $threshold = 10;
  
  // --- Create revision data
  // Check if node was revised
    if (($vars['status']) && $vars['changed'] && (round(($vars['changed'] - $vars['published_at']) / $time_unit) > $threshold)){
    $vars['submitted'] =
      t('Published: !publishtime | Updated: !updatetime | Author: !username', array( '!publishtime' => format_date($vars['published_at'],'custom','d M Y'), '!updatetime' => format_date($vars['changed'],'custom','d M Y'), '!username' => $vars['name']));
  } else {
    $vars['submitted'] =
      t('Published: !publishtime | Author: !username', array( '!publishtime' => format_date($vars['published_at'],'custom','d M Y'), '!username' => $vars['name'])); 
  }

}

che potrebbe anche essere usata come funzione node preprocess in template.php.

AllegatoDimensione
Package icon publication_date_update-7.x.zip1.04 KB
Section: 

Commenti

Aggiungi un commento