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

Small code cleanup.

parent 81d7adcc
......@@ -3,27 +3,22 @@
function simplesitemap_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
if ($form_id == 'node_type_edit_form') {
// Setting defaults.
$index_content_checked = FALSE;
$priority = 0.5;
$content_types = \Drupal::config('simplesitemap.settings')->get('content_types');
if (isset($content_types[$form['type']['#default_value']]['index'])) {
$index_content_checked = $content_types[$form['type']['#default_value']]['index'] ? TRUE : FALSE;
if (isset($content_types[$form['type']['#default_value']]['priority']))
$priority = $content_types[$form['type']['#default_value']]['priority'];
}
$form['simplesitemap'] = array(
'#group' => 'additional_settings',
'#title' => 'Simple XML sitemap',
'#type' => 'details'
);
$index_content_checked = isset($content_types[$form['type']['#default_value']]['index']) ? $content_types[$form['type']['#default_value']]['index'] : FALSE;
$form['simplesitemap']['simplesitemap_index_content'] = array(
'#type' => 'checkbox',
'#title' => 'Index content of this type',
'#default_value' => $index_content_checked,
);
$priority = isset($content_types[$form['type']['#default_value']]['priority']) ? $content_types[$form['type']['#default_value']]['priority'] : 0.5;
$form['simplesitemap']['simplesitemap_priority'] = array(
'#type' => 'select',
'#title' => 'Priority',
......
......@@ -22,25 +22,21 @@ class SimplesitemapController {
$config = \Drupal::config('simplesitemap.settings');
$content_types = $config->get('content_types');
// $config->set('content_types', array('blog'));
// $config->save();
$output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">";
global $base_url;
$home = $config->get('home');
if ($home['index']) {
if ($home['index'])
$output .= "<url><loc>" . $base_url . "</loc><priority>" . $home['priority'] . "</priority></url>";
}
$custom = $config->get('custom');
foreach($custom as $page) {
if ($page['index']) {
if ($page['index'])
$output .= "<url><loc>" . $base_url . '/' . $page['path'] . "</loc><priority>" . $page['priority'] . "</priority></url>";
}
}
if (count($content_types) > 0) {
//todo: D8 entityQuery doesn't seem to take multiple OR conditions, that's why that ugly db_select.
......
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