Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function itf_menu() {
- $items = array();
- $items['sitemap'] = array(
- 'title' => t('Sitemap'),
- 'page callback' => 'itf_sitemap',
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- );
- return $items;
- }
- function itf_sitemap() {
- $tree = menu_tree_all_data('menu-views4sitemap');
- $links = array();
- foreach ($tree as $item) {
- $links[] = array(
- 'data' => l($item['link']['title'], $item['link']['link_path']),
- 'children' => itf_sitemap_get_children($item)
- );
- }
- $title = '<h1>' . t('Sitemap') . '</h1>';
- return $title . theme_item_list($links);
- }
- function itf_sitemap_get_children($item) {
- $children = array();
- $node_types = node_get_types();
- if ($item['below']) {
- foreach ($item['below'] as $subitem) {
- $children[] = array(
- 'data' => l($subitem['link']['title'], $subitem['link']['link_path']),
- 'children' => itf_sitemap_get_children($subitem)
- );
- }
- }
- elseif (array_key_exists($item['link']['link_path'], $node_types)) {
- $result = db_query('SELECT `nid`, `title` FROM `node` WHERE `type` = "%s" AND status=1', $item['link']['link_path']);
- while ($row = db_fetch_object($result)) {
- $children[] = array('data' => l($row->title, 'node/' . $row->nid));
- }
- }
- elseif ($term = taxonomy_get_synonym_root($item['link']['link_path'])) {
- $result = taxonomy_select_nodes(array($term->tid));
- while ($row = db_fetch_object($result)) {
- $children[] = array('data' => l($row->title, 'node/' . $row->nid));
- }
- }
- return $children;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement