Skip to content

Commit

Permalink
Bugfixes: Error while no language is selected; Improvements: Checkbox…
Browse files Browse the repository at this point in the history
… for disabling generating sitemap
  • Loading branch information
ReoKzK committed Feb 21, 2017
1 parent 9a97e48 commit c24e902
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 3 deletions.
Binary file removed Package/SitecoreDynamicSitemapXML-1.0.1.zip
Binary file not shown.
Binary file added Package/SitecoreDynamicSitemapXML-1.0.3.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions Sitecore.SharedSource.DynamicSitemap/Constants/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ public static class Messages
public static readonly String ExecutionInterrupted = Label + "There are no sitemap configurations, execution interrupted.";
public static readonly String NoConfigurations = Label + "There are no sitemap configurations.";
public static readonly String NoGlobalScConfiguration = Label + "There is no global Sitecore configuration Item.";
public static readonly String NoProcessedLanguages = Label + "There are no processed languages selected in global configuration.";

public static readonly String ExceptionWhileBuilding = Label + "Exception while building sitemap for {0} - {1}\n\n{2}";

public static readonly String SitemapBuildSuccess = Label + "Sitemap generated - {0}";
public static readonly String SitemapDisabled = Label + "Sitemap generation is disabled";

public static readonly String SitemapSubmitterCannotSubmit = Label + "Cannot submit sitemap to \"{0}\" - {1}";
public static readonly String SitemapSubmitterExceptionWhileSubmit = Label + "Search engine submission \"{0}\" returns an error - {1} \n\n{2}";
Expand Down
20 changes: 17 additions & 3 deletions Sitecore.SharedSource.DynamicSitemap/DynamicSitemapGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,28 @@ public void ReadConfigurations()
{
ReadGlobalSitecoreConfiguration();

SiteConfigurations = new List<SitemapSiteConfiguration>();

if (SitecoreConfiguration.DisableSitemap)
{
Sitecore.Diagnostics.Log.Warn(Messages.SitemapDisabled, this);
return;
}

Item[] configurationItems = Database.SelectItems(DynamicSitemapConfiguration.SitemapConfigurationItemPath + DynamicSitemapConfiguration.SitemapConfigurationSitesFolderName + "/*[@@templateid='" + TemplateIds.SiteConfigurationTemplateId + "']");

if (configurationItems.Count() == 0)
{
Sitecore.Diagnostics.Log.Warn(Messages.NoConfigurations, this);
return;
}

SiteConfigurations = new List<SitemapSiteConfiguration>();


if (SitecoreConfiguration.ProcessedLanguages.Count() == 0)
{
Sitecore.Diagnostics.Log.Warn(Messages.NoProcessedLanguages, this);
return;
}

foreach (var configurationItem in configurationItems)
{
var languageItems = configurationItem.Languages.Where(x => SitecoreConfiguration.ProcessedLanguages.Contains(x.Name)).ToList();
Expand Down Expand Up @@ -198,6 +210,8 @@ protected void ReadGlobalSitecoreConfiguration()
SitecoreConfiguration.MainSiteConfigurationItem = mainSiteConfiguration;
}

SitecoreConfiguration.DisableSitemap = globalConfigurationItem["Disable sitemap generation"] == "1";

SitecoreConfiguration.SearchEngines = !String.IsNullOrEmpty(globalConfigurationItem["Search Engines"])
? globalConfigurationItem["Search Engines"].Split('|').ToList()
: new List<String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace Sitecore.SharedSource.DynamicSitemap.Model
/// </summary>
public class DynamicSitemapSitecoreConfiguration
{
/// <summary>
/// If disable whole sitemap generation
/// </summary>
public bool DisableSitemap { get; set; }

/// <summary>
/// Configuration that will be used as main
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
ID: "b0e21af0-0e62-4047-9859-73d57074320c"
Parent: "8e0bf0cc-49a9-4d96-9b50-17c353a6c03e"
Template: "e269fbb5-3750-427a-9149-7aa950b49301"
Path: /sitecore/templates/Dynamic Sitemap XML/Global Configuration/General
DB: master
SharedFields:
- ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
Hint: __Sortorder
Value: 50
Languages:
- Language: en
Versions:
- Version: 1
Fields:
- ID: "25bed78c-4957-4165-998a-ca1b52f67497"
Hint: __Created
Value: 20170221T112452Z
- ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
Hint: __Created by
Value: sitecore\admin
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
ID: "46b23caf-b9ce-4365-aca7-9ba810199714"
Parent: "b0e21af0-0e62-4047-9859-73d57074320c"
Template: "455a3e98-a627-4b40-8035-e683a0331ac7"
Path: /sitecore/templates/Dynamic Sitemap XML/Global Configuration/General/Disable sitemap generation
DB: master
SharedFields:
- ID: "ab162cc0-dc80-4abf-8871-998ee5d7ba32"
Hint: Type
Value: Checkbox
- ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
Hint: __Sortorder
Value: 100
- ID: "be351a73-fcb0-4213-93fa-c302d8ab4f51"
Hint: Shared
Type: Checkbox
Value: 1
Languages:
- Language: en
Versions:
- Version: 1
Fields:
- ID: "25bed78c-4957-4165-998a-ca1b52f67497"
Hint: __Created
Value: 20170221T112452Z

0 comments on commit c24e902

Please sign in to comment.