From 59aef40b84fbeb454e1eca0b8116544b633097dd Mon Sep 17 00:00:00 2001 From: Pawel G Date: Tue, 7 Jun 2016 21:49:37 +0200 Subject: [PATCH] Make changes to readme file and prettify sitemap entity page. --- README.txt | 40 +++++++++++++++----------- src/Form/SimplesitemapEntitiesForm.php | 15 ++++++---- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/README.txt b/README.txt index 2b86b53..8fa9960 100644 --- a/README.txt +++ b/README.txt @@ -5,6 +5,7 @@ CONTENTS OF THIS FILE * Installation * Configuration * Usage + * Extending the module * How Can You Contribute? * Maintainers @@ -15,16 +16,17 @@ INTRODUCTION Author and maintainer: Pawel Ginalski (gbyte.co) https://www.drupal.org/u/gbyte.co The module generates a multilingual XML sitemap which adheres to Google's new -hreflang standard. Out of the box the sitemap is able to index the following -content: +hreflang standard. Out of the box the sitemap is able to index most of Drupal's +content entity types including: * nodes * taxonomy terms * menu links * users - * custom links - * commerce products - * possibly other contributed entities + * ... + +Contributed entity types like commerce products or media entities can be indexed +as well. On top of that custom links can be added to the sitemap. To learn about XML sitemaps, see https://en.wikipedia.org/wiki/Sitemaps. @@ -43,20 +45,23 @@ The module permission 'administer sitemap settings' can be configured under /admin/people/permissions. Initially only the home page is indexed in the sitemap. To include content into -the sitemap, visit the corresponding entity bundle edit pages, e.g. +the sitemap, visit /admin/config/search/simplesitemap/entities to enable support +for entity types of your choosing. Entity types which feature bundles can then +be configured on a per-bundle basis, e.g. - * /admin/structure/types/manage/[content type] for nodes, - * /admin/structure/taxonomy/manage/[taxonomy vocabulary] for taxonomy terms, - * /admin/structure/menu/manage/[menu] for menu items, - * /admin/config/people/accounts for users + * /admin/structure/types/manage/[content type] for nodes + * /admin/structure/taxonomy/manage/[taxonomy vocabulary] for taxonomy terms + * /admin/structure/menu/manage/[menu] for menu items + * ... -When including an entity bundle into the sitemap, the priority setting can be -set which will set the 'priority' parameter for all entities of that type. See -https://en.wikipedia.org/wiki/Sitemaps to learn more about this parameter. +When including an entity type or bundle into the sitemap, the priority setting +can be set which will set the 'priority' parameter for all entities of that +type. See https://en.wikipedia.org/wiki/Sitemaps to learn more about this +parameter. Inclusion and priority settings of bundles can be overridden on a per-entity -basis. Just head over to a bundle instance edit form (node/1/edit) and override -the bundle settings there. +basis. Just head over to a bundle instance edit form (e.g. node/1/edit) to +override its sitemap settings. If you wish for the sitemap to reflect the new configuration instantly, check 'Regenerate sitemap after clicking save'. This setting only appears if a change @@ -97,8 +102,8 @@ link array. HOW CAN YOU CONTRIBUTE? ----------------------- - * Report any bugs, feature or support requests in the issue tracker, if possible - help out by submitting patches. + * Report any bugs, feature or support requests in the issue tracker, if + possible help out by submitting patches. http://drupal.org/project/issues/simple_sitemap * Do you know a non-English language? Help translating the module. @@ -114,3 +119,4 @@ MAINTAINERS Current maintainers: * Pawel Ginalski (gbyte.co) - https://www.drupal.org/u/gbyte.co + * Sam Becker (Sam152) - https://www.drupal.org/u/sam152 diff --git a/src/Form/SimplesitemapEntitiesForm.php b/src/Form/SimplesitemapEntitiesForm.php index 7fc83ea..9aee453 100644 --- a/src/Form/SimplesitemapEntitiesForm.php +++ b/src/Form/SimplesitemapEntitiesForm.php @@ -41,19 +41,24 @@ class SimplesitemapEntitiesForm extends ConfigFormBase { $form['simple_sitemap_entities']['entities'] = array( '#title' => t('Sitemap entities'), '#type' => 'fieldset', - '#markup' => '

' . t("Simple XML sitemap settings will be added only to entity forms of entity types enabled here. For all entity types featuring bundles (e.g. node) inclusion settings have to be set on their bundle pages (e.g. 'page'). Disabling an entity type on this page will irreversibly delete its sitemap settings including per-entity overrides.") . '

', + '#markup' => '

' . t("Simple XML sitemap settings will be added only to entity forms of entity types enabled here. For all entity types featuring bundles (e.g. node) inclusion settings have to be set on their bundle pages (e.g. page). Disabling an entity type on this page will delete its sitemap settings including per-entity overrides.") . '

', ); - $sitemap_entity_types = Simplesitemap::getSitemapEntityTypes(); + $entity_type_labels = []; + foreach (Simplesitemap::getSitemapEntityTypes() as $entity_type_id => $entity_type) { + $entity_type_labels[$entity_type_id] = $entity_type->getLabel() ? : $entity_type_id; + } + asort($entity_type_labels); + $entity_types = $sitemap->getConfig('entity_types'); $f = new Form(); - foreach ($sitemap_entity_types as $entity_type_id => $entity_type) { - $entity_type_label = $entity_type->getLabel() ? : $entity_type_id; + foreach ($entity_type_labels as $entity_type_id => $entity_type_label) { $entity_type_enabled = isset($entity_types[$entity_type_id]); $form['simple_sitemap_entities']['entities'][$entity_type_id] = [ - '#type' => 'fieldset', + '#type' => 'details', '#title' => $entity_type_label, + '#open' => $entity_type_enabled, ]; $form['simple_sitemap_entities']['entities'][$entity_type_id][$entity_type_id . '_enabled'] = [ '#type' => 'checkbox', -- GitLab