2

I have a website with SXA (1.7.1) and language fallback setup up. It all works fine for regular components (eg. carousel or a custom component made by us) but lists (eg. Link List) won't pick up fallback items.

So the problem is as follows:

  1. There is a Link List component on the page
  2. There is datasource with list of links in the Data section
  3. The datasource and the links all have only english version
  4. I am opening the page in de-de language and I can't see any of the links (the component itself is visible - I can see div.component.link-list in the source)
  5. The problem above does not happen on carousel for example (so I have slides in English and see them all in German version).

I had a similar issue in SXA 1.2 and I digged into LinkListRepository which inherits from ListRepository where there is a GetItem() method. This method uses extension method GetItemsWithVersion() from ItemExtensions class. I think this might cause the problem with language fallback - the items are just not returned if there is no version. Moreover in the extension method there is a following piece of code used:

i.Versions.GetVersions(Sitecore.Context.PageMode.IsExperienceEditorEditing)

and the items are visible in edit mode.

The questions from my side:

  1. Is this correct behavior of a bug?
  2. Is there any hidden mechanism to enable language fallback on list components?
  3. If not, how can I override LinkListRepository to fix this problem? I cannot find it registered in the the <services> section so I could replace it with my own implementation? I have a custom Link List component and custom repository registered but apparently it gets overriden by original LinkListRepository being registered later on. This method worked in SXA 1.2.

UPDATE

I have managed to workaround this problem by moving my configurator class which creates an instance of ILinkListRepository to the end of the <service> section.

Which leaves me with question: Where on earth are you instantiating your class? Plus confirm please if this is expected or a bug.

4
  1. Is this correct behavior of a bug?

This as a bug. This code simply does what it says. It will not work with language fallback which is not expected.

  1. Is there any hidden mechanism to enable language fallback on list components?

Nope, you have to overwrite it or ask support for a hotfix.

  1. I cannot find it registered in the section so I could replace it with my own implementation
  1. In this config Sitecore.XA.Foundation.IoC.config you will find configurator node
  2. This class Sitecore.XA.Foundation.IoC.ServiceCollection.RegisterMvcControllersIoC does something like serviceCollection.AddMvcControllers("namespace");
  3. Somewhere inside AddMvcControllers you will find:
var repositories = GetTypesImplementing<IControllerRepository>(assemblies)
                .Where(repo => repo.Name.EndsWith("Repository", StringComparison.Ordinal));

(later all of them are registered automatically)

This does the whole job. Notice that every repository inherits from Sitecore.XA.Foundation.IoC.IControllerRepository

I don't have exact steps on how to overwrite it.

  • For the record - I have created a Configurator class where I am registering my own implementation of LinkListRepository where the problem is fixed (I am overriding GetItems() method). It didn't work because I have been registering my implementation before RegisterMvcControllersIoC class – Szymon Kuzniak Feb 14 at 13:02
  • @SzymonKuzniak You should not register new service but replace the existing one. In such a case, you don't need to bother about the order. Take a look for example here: stackoverflow.com/questions/43590769/… – Dawid Rutkowski Feb 14 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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