Created
August 31, 2017 14:55
-
-
Save 5up3rman/d1fbd3443208d788cd0696ffab446be4 to your computer and use it in GitHub Desktop.
An old Item Renamer from 2011. Very flawed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EnforceItemName | |
{ | |
protected void OnItemSaved(object sender, EventArgs args) | |
{ | |
var currentItem = Sitecore.Events.SitecoreEventArgs.GetItem(args, 0); | |
if (currentItem != null && currentItem.Name.Contains(" ") && (currentItem.Paths.IsContentItem || currentItem.Paths.IsMediaItem)) | |
{ | |
currentItem.Editing.BeginEdit(); | |
string displayName = currentItem.DisplayName; | |
currentItem.Name = currentItem.Name.ToItemName().ToLower(); | |
currentItem.Appearance.DisplayName = displayName; | |
currentItem.Editing.EndEdit(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment