Advertisement
Guest User

Untitled

a guest
Aug 24th, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <?php
  2. function itf_menu() {
  3. $items = array();
  4. $items['sitemap'] = array(
  5. 'title' => t('Sitemap'),
  6. 'page callback' => 'itf_sitemap',
  7. 'access arguments' => array('access content'),
  8. 'type' => MENU_CALLBACK,
  9. );
  10. return $items;
  11. }
  12.  
  13. function itf_sitemap() {
  14. $tree = menu_tree_all_data('menu-views4sitemap');
  15.  
  16. $links = array();
  17. foreach ($tree as $item) {
  18. $links[] = array(
  19. 'data' => l($item['link']['title'], $item['link']['link_path']),
  20. 'children' => itf_sitemap_get_children($item)
  21. );
  22. }
  23. $title = '<h1>' . t('Sitemap') . '</h1>';
  24. return $title . theme_item_list($links);
  25. }
  26.  
  27. function itf_sitemap_get_children($item) {
  28. $children = array();
  29. $node_types = node_get_types();
  30.  
  31. if ($item['below']) {
  32. foreach ($item['below'] as $subitem) {
  33. $children[] = array(
  34. 'data' => l($subitem['link']['title'], $subitem['link']['link_path']),
  35. 'children' => itf_sitemap_get_children($subitem)
  36. );
  37. }
  38. }
  39. elseif (array_key_exists($item['link']['link_path'], $node_types)) {
  40. $result = db_query('SELECT `nid`, `title` FROM `node` WHERE `type` = "%s" AND status=1', $item['link']['link_path']);
  41. while ($row = db_fetch_object($result)) {
  42. $children[] = array('data' => l($row->title, 'node/' . $row->nid));
  43. }
  44. }
  45. elseif ($term = taxonomy_get_synonym_root($item['link']['link_path'])) {
  46. $result = taxonomy_select_nodes(array($term->tid));
  47. while ($row = db_fetch_object($result)) {
  48. $children[] = array('data' => l($row->title, 'node/' . $row->nid));
  49. }
  50. }
  51.  
  52. return $children;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement