Commit 5c497bd6 authored by gbyte.co's avatar gbyte.co

Fix for sitemap not reflecting content type settings.

parent 5fc406b1
...@@ -20,7 +20,6 @@ class SimplesitemapController { ...@@ -20,7 +20,6 @@ class SimplesitemapController {
public function generate_sitemap() { public function generate_sitemap() {
$config = \Drupal::config('simplesitemap.settings'); $config = \Drupal::config('simplesitemap.settings');
$content_types = $config->get('content_types');
$output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> $output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"; <urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">";
...@@ -37,6 +36,7 @@ class SimplesitemapController { ...@@ -37,6 +36,7 @@ class SimplesitemapController {
$output .= "<url><loc>" . $base_url . '/' . $page['path'] . "</loc><priority>" . $page['priority'] . "</priority></url>"; $output .= "<url><loc>" . $base_url . '/' . $page['path'] . "</loc><priority>" . $page['priority'] . "</priority></url>";
} }
$content_types = $config->get('content_types');
if (count($content_types) > 0) { if (count($content_types) > 0) {
//todo: D8 entityQuery doesn't seem to take multiple OR conditions, that's why that ugly db_select. //todo: D8 entityQuery doesn't seem to take multiple OR conditions, that's why that ugly db_select.
...@@ -49,7 +49,8 @@ class SimplesitemapController { ...@@ -49,7 +49,8 @@ class SimplesitemapController {
->condition('status', 1); ->condition('status', 1);
$db_or = db_or(); $db_or = db_or();
foreach($content_types as $machine_name => $options) { foreach($content_types as $machine_name => $options) {
$db_or->condition('type', $machine_name); if ($options['index'])
$db_or->condition('type', $machine_name);
} }
$query->condition($db_or); $query->condition($db_or);
$nids = $query->execute()->fetchAllAssoc('nid'); $nids = $query->execute()->fetchAllAssoc('nid');
......
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