Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. function trails_init() {
  2.  
  3.   // Grab the trail history from a variable
  4.   $trail = variable_get('trails_history', array());
  5.  
  6.   // Add current page to test array
  7.   $testarray = array(
  8.     'title' => strip_tags(drupal_get_title()),
  9.     'path' => $_GET['q'],
  10.     'timestamp' => REQUEST_TIME,
  11.   );
  12.  
  13.   $new_trails = $trail;
  14.  
  15.   //If the current trail array has a matching title with the test array, then just set time.
  16.   foreach ($trail as $trailvalue){
  17.     //check the titles
  18.     if ($trailvalue['title'] == $testarray['title']){
  19.       $trailvalue['timestamp'] = REQUEST_TIME;
  20.     }
  21.     //else add the $testarray array to the next
  22.     else {
  23.       $new_trails[] = $testarray;
  24.     }
  25.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement