0

I have inherited my items from _HasValidUrlName template, that should create valid item name. for example replace spaces to dash. but item display name would be equal to user input.

but at Sitecore 9 it is not working by some reason, at Sitecore 8 it was ok.

does anyone know why ?

4
  • Could you provide more information on this? How does the functionality of ensuring the item name is valid work?
    – Kasaku
    Commented Nov 25, 2019 at 18:28
  • @Kasaku for example when user create item with spaces like "My Page" item name would be my-page, but display name would be "My Page" Commented Nov 26, 2019 at 7:59
  • _HasValidUrlName sounds like a custom template? Can you elaborate how this enforced a valid name in you Sitecore 8 solution? Commented Dec 2, 2019 at 22:55
  • @BryanArcher It's related to SXA, something ootb using that module
    – jammykam
    Commented Dec 2, 2019 at 23:00

3 Answers 3

2

Which version of SXA are you using?

Based on what I have come across, _HasValidUrlName is used in Sitecore.XA.Foundation.ContentValidation to check if the item being created is inherited from _HasValidUrlName template but it doesn't check for what you are looking for atleast in Sitecore SXA 1.8

public struct _SeoUrlValid
{
  public static ID ID = ID.Parse("{0A7DA0A0-FCD9-4B7B-A725-E159FA3E7E6C}");
}

protected virtual bool ShouldValidate(Item item)
{
  return item.DoesItemInheritFrom(Sitecore.XA.Foundation.ContentValidation.Templates._SeoUrlValid.ID);
}

You can start from there and dig further. Hope it helps!

1
  • sitecore 9.2 and sxa 1.9 Commented Dec 4, 2019 at 18:28
0

The reason is that this part was move out from SXA configs settings

 <events>
          <event name="item:added">
            <handler patch:after="*[@type='Sitecore.Data.Fields.ItemEventHandler, Sitecore.Kernel']" type="Sitecore.XA.Foundation.ContentValidation.EventHandlers.SeoUrlHelper, Sitecore.XA.Foundation.ContentValidation" method="OnItemAdded"/>
          </event>
          <event name="item:renamed">
            <handler type="Sitecore.XA.Foundation.ContentValidation.EventHandlers.SeoUrlHelper, Sitecore.XA.Foundation.ContentValidation" method="OnItemRenamed"/>
          </event>
          <event name="item:copied">
            <handler patch:after="*[@type='Sitecore.Tasks.ItemEventHandler, Sitecore.Kernel']" type="Sitecore.XA.Foundation.ContentValidation.EventHandlers.SeoUrlHelper, Sitecore.XA.Foundation.ContentValidation" method="OnItemCopied"/>
          </event>
        </events>
0

We came across this issue where the item names are no longer renamed to lowercase with dashes (which includes the updated Display Name). After stumbling across this post I thought I would add a few comments.

  1. Some time after Sitecore 8.2.7 the class Sitecore.XA.Foundation.ContentValidation.EventHandlers.SeoUrlHelper was removed and the associated event config as noted by @Arbejdsglæde. I'm guessing Sitecore 9.0 or 9.1.
  2. When we transitioned to Sitecore 9.3 we did not notice this behavior change. The URLs still generate on the live site with dashes so no one complained.
  3. We have a custom LinkProvider to lowercase URLs and a custom ItemProvider to ensure the trailing forward slash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.