Jojo
Jojo

Reputation: 403

Not able to add Item having '-' in name to Sitecore

I'm trying to add a language in system=>languages which have name nl-Nl But Sitecore alerting an error

An item name cannot contain any of the following characters:
\/:?"<>|[]- (controlled by the setting InvalidItemNameChars)

My web.config file have

<!--  INVALID CHARS
            Characters that are invalid in an item name
      -->
      <setting name="InvalidItemNameChars" value="\/:?&quot;&lt;&gt;|[]" />
      <!--  ITEM NAME VALIDATION
            Regular expression for validating item names
      -->
      <setting name="ItemNameValidation" value="^[\w\*\$][\w\s\-\$]*(\(\d{1,}\)){0,1}$" />

This same thing I can do in another Sitecore without any error

My sitecore version is: Sitecore.NET 7.2 (rev. 140526)

Upvotes: 0

Views: 2217

Answers (1)

jammykam
jammykam

Reputation: 16990

The error, as you correctly identified, is due to the InvalidItemNameChars setting which restricts item names from having -. You will have to remove this value, add the item and then add the setting back in.

Since the web.config has the default Sitecore value, the setting will be patched in using a patch include which you can find located in /App_Config/Include/ folder or in one of the sub-folders located in there. Check your Visual Studio project, which that will give you the best clue to exactly which file modifies this value.

The restriction was likely added, in combination with an encodeNameReplacement value, to make the URLs look SEO friendly. Longer term you may want to consider something like this as a better solution: https://jammykam.wordpress.com/2015/07/13/seo-friendly-urls-in-sitecore-prevention-is-better-than-cure/

Upvotes: 4

Related Questions