Commit 12d0d1d3 authored by RenatoG's avatar RenatoG Committed by pifagor

Issue #2663632 by ryan.gibson, RenatoG, Michelle, Chris Matthews, pifagor:...

Issue #2663632 by ryan.gibson, RenatoG, Michelle, Chris Matthews, pifagor: Exclude unaliased paths from sitemap
parent a50c2df4
......@@ -408,6 +408,11 @@ function xmlsitemap_settings_form($form, &$form_state) {
'#default_value' => variable_get('xmlsitemap_disable_cron_regeneration', 0),
'#description' => t('This can be disabled if other methods are being used to generate the sitemap files, like <em>drush xmlsitemap-regenerate</em>.'),
);
$form['advanced']['xmlsitemap_skip_unaliased'] = array(
'#type' => 'checkbox',
'#title' => t('Skip unaliased nodes when generating sitemap.'),
'#default_value' => variable_get('xmlsitemap_skip_unaliased', 0),
);
$form['advanced']['xmlsitemap_output_elements'] = array(
'#type' => 'checkboxes',
'#title' => t('Enable or disable the individual @loc elements from output', array('@loc' => '<loc>')),
......
......@@ -259,6 +259,11 @@ function xmlsitemap_generate_chunk(stdClass $sitemap, XMLSitemapWriter $writer,
// @todo Should this be moved to XMLSitemapWritier::writeSitemapElement()?
drupal_alter('xmlsitemap_element', $element, $link, $sitemap);
// If the setting to skip unaliased nodes is enabled, and there is no alias
// for the node, don't write it to the sitemap.
if (variable_get('xmlsitemap_skip_unaliased', 0) && strpos($element['loc'], "node") !== FALSE) {
$element = "";
}
if (!empty($element)) {
$writer->writeSitemapElement('url', $element);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment