diff --git a/xmlsitemap_file/xmlsitemap_file.info b/xmlsitemap_file/xmlsitemap_file.info new file mode 100644 index 0000000..c446806 --- /dev/null +++ b/xmlsitemap_file/xmlsitemap_file.info @@ -0,0 +1,8 @@ +name = XML sitemap file +description = Adds files to sitemap.xml. +package = XML sitemap +core = 7.x + +dependencies[] = file_entity +dependencies[] = xmlsitemap +dependencies[] = xmlsitemap_entity diff --git a/xmlsitemap_file/xmlsitemap_file.module b/xmlsitemap_file/xmlsitemap_file.module new file mode 100644 index 0000000..5438b73 --- /dev/null +++ b/xmlsitemap_file/xmlsitemap_file.module @@ -0,0 +1,41 @@ +type) ? $form['#file_type']->type : ''; + module_load_include('inc', 'xmlsitemap', 'xmlsitemap.admin'); + xmlsitemap_add_link_bundle_settings($form, $form_state, 'file', $bundle); + // Add form element to append /download to path. + $default = variable_get('xmlsitemap_settings_file_' . $bundle , FALSE); + $download = isset($default['download']) ? $default['download'] : FALSE ; + $form['xmlsitemap']['download'] = array( + '#type' => 'checkbox', + '#title' => t('Append "/download" to support indexing of the attached file - as opposed to the Drupal file entity. Useful for attached text files (.pdf, .txt, .doc, etc).'), + '#default_value' => $download, + ); +} + +/** + * Implements hook_xmlsitemap_element_alter + */ +function xmlsitemap_file_xmlsitemap_element_alter(array &$element, array $link, $sitemap) { + // See definition of hook_xmlsitemap_element_alter in xmlsitemap.api.php for + // sample code to add additonal element info or metadata. + if ($link['type'] == 'file') { + // Verify that this file subtype needs /download appended to it's path + $bundle = $link['subtype']; + $config = variable_get('xmlsitemap_settings_file_' . $bundle , FALSE); + $download = isset($config['download']) ? $config['download'] : FALSE ; + + if ($download) { + $element['loc'] .= '/download'; + } + } +}