---
 sites/all/modules/site_map/site_map.admin.inc |   14 +++++
 sites/all/modules/site_map/site_map.module    |   67 +++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/sites/all/modules/site_map/site_map.admin.inc b/sites/all/modules/site_map/site_map.admin.inc
index ffbb216..ad6c143 100644
--- a/sites/all/modules/site_map/site_map.admin.inc
+++ b/sites/all/modules/site_map/site_map.admin.inc
@@ -82,6 +82,20 @@ function site_map_admin_settings() {
     '#default_value' => variable_get('site_map_show_faq', 0),
     '#description' => t('When enabled, this option will include the content from the FAQ module in the site map.'),
   );
+  
+  $node_types = node_get_types();
+  foreach($node_types as $key => $value){
+    $node_type_list[$key] = $value->name;
+  } 
+  $form['site_map_content']['site_map_exclude_node_types'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Node types to exclude from the site map'),
+    '#default_value' => variable_get('site_map_exclude_node_types', array()),
+    '#options' => $node_type_list,
+    '#multiple' => TRUE,
+  	'#description' => t('Nodes which have the checked node types won\'t be shown in the site map.')
+  );
+  
   $vocab_options = array();
   if (module_exists('taxonomy')) {
     foreach (taxonomy_get_vocabularies() as $vocabulary) {
diff --git a/sites/all/modules/site_map/site_map.module b/sites/all/modules/site_map/site_map.module
index 1a672d4..5451831 100644
--- a/sites/all/modules/site_map/site_map.module
+++ b/sites/all/modules/site_map/site_map.module
@@ -433,6 +433,9 @@ function _site_map_taxonomy_tree($vid, $name = NULL, $description = NULL) {
 function _site_map_menu_tree_output($tree) {
   $output = '';
   $items = array();
+  
+  // Exclude node types from site map
+  _site_map_hide_node_types($tree);
 
   // Pull out just the menu items we are going to render so that we
   // get an accurate count for the first/last classes.
@@ -461,3 +464,67 @@ function _site_map_menu_tree_output($tree) {
   }
   return $output ? theme('site_map_menu_tree', $output) : '';
 }
+
+/**
+ * Marks node menu items as hidden if their node types was configured to be
+ * not shown on the site map.
+ * 
+ * @param $tree		Menu tree as returned fro menu_tree_data
+ * @return modified $tree with some menu items hidden 
+ */
+function _site_map_hide_node_types(&$tree){
+  // Which node types are excluded from the site map is configured in the 
+  // site map admin menu.
+  $hidden_node_types = variable_get('site_map_exclude_node_types', array());
+  // Only proceed if an exclude node type configuration was made
+  if (count($hidden_node_types) > 0 ) {
+    // Determine the node type for each node menu item
+    $menu_table = _site_map_get_table_mlid_to_node();
+    $node_types = _site_map_get_table_node_to_type();
+    
+    // Mark node menu items hidden which are configured as hidden
+    foreach ($tree as &$tree_item){
+      $mlid = $tree_item['link']['mlid'];
+      $type = $node_types[$menu_table[$mlid]];
+      if ($hidden_node_types[$type]){
+        $tree_item['link']['hidden'] = true;
+      }
+    }
+  }  
+}
+
+/**
+ * Get all menu items that are linking to nodes and their corresponding NIDs.
+ * The resulting array does not contain menu items that do not link to nodes.
+ * 
+ * @return array( key = mlid, value = nid)
+ */
+function _site_map_get_table_mlid_to_node(){
+  $sql = 'SELECT mlid, link_path, router_path FROM menu_links WHERE router_path = "node/%"';
+  $result = db_query($sql);
+  $menu_table = array();
+  while($row = db_fetch_array($result)){
+    $link_exploded = explode('/', $row['link_path']);
+    $nid = $link_exploded[1];
+    // Check if the nid is a number
+    if (preg_match('/[0-9]+/', $nid)){
+      $menu_table[$row['mlid']] = $nid;
+    }
+  }
+  return $menu_table;
+}
+
+/**
+ * Get all node ids and their types.
+ * 
+ * @return array( key = nid, value = type)
+ */
+function _site_map_get_table_node_to_type(){
+  $sql = 'SELECT nid, type FROM node';
+  $result = db_query($sql);
+  $node_types = array();
+  while($row = db_fetch_array($result)){
+    $node_types[$row['nid']] = $row['type'];
+  }
+  return $node_types;
+}
-- 
1.5.4.3

