Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. <?php
  2.  
  3. function path_redirect_newest_menu() {
  4. $items['media/gallery'] = array(
  5. 'page callback' => 'path_redirect_newest_gallery',
  6. 'access callback' => TRUE,
  7. );
  8. return $items;
  9. }
  10.  
  11. function path_redirect_newest_gallery() {
  12. $query = new EntityFieldQuery();
  13. $query->entityCondition('entity_type', 'node')
  14. ->entityCondition('bundle', 'gallery_album')
  15. ->propertyCondition('status', 1)
  16. ->propertyOrderBy('created', 'DESC')
  17. ->range(0, 1);
  18.  
  19. $result = $query->execute();
  20. $node = $result['node'];
  21. reset($node);
  22. $nid = key($node);
  23.  
  24. drupal_goto('node/' . $nid);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement