1

We have migrated from Sitecore 7.2 to Sitecore 9.1 version and maintaining four websites.

Since it is a multi-site solution and they wanted to use the field "Datasource Location" and "Datasource template" on sublayouts to open the datasource selection that would help content author to select the datasource folders dynamically. For that purpose, they have added below custom module earlier. Below is the code.

We have migrated from Sitecore 7.2 to Sitecore 9.1 version and maintaining four websites.

Since it is a multi-site solution and they wanted to use the field "Datasource Location" and "Datasource template" on sublayouts to open the datasource selection that would help content author to select the datasource folders dynamically. For that purpose, they have added below custom module earlier. Below is the code.

public class GetQueryableDatasourceLocation
{
  public void Process(GetRenderingDatasourceArgs args)
  {
    foreach (var location in
        new ListString(args.RenderingItem["Datasource Location"]))
    {
      if (location.StartsWith("query:"))
      {
        Item contextItem = args.ContentDatabase.Items[args.ContextItemPath];
        if (contextItem != null)
        {
          string query = location.Substring("query:".Length);
          Item queryItem = contextItem.Axes.SelectSingleItem(query);
          if (queryItem != null)
          {
            args.DatasourceRoots.Add(queryItem);
          }
        }
      }
    }
  }
}

It has been added in the getRenderingDatasource pipeline.

We are going to develop a new website using SXA. Whenever we use any components (Rich Text or Promo, Carousel etc), it is keep loading in the experience editor and getting below error in the logs. enter image description here

Further Reference: https://sitecoreblog.blogspot.com/2012/06/sublayout-queryable-datasource-module.html

Has anyone come across this scenario and How to resolve the issue. Kindly share your inputs?

1
  • Your custom code is probably interfering with the ootb SXA code. Make sure your custom code is not executed in the context of an SXA site.. that will probably fix it.
    – Gatogordo
    May 12, 2019 at 8:36

1 Answer 1

3

I think you can safely get rid of that code, and probably should. When you install SXA on your solution you automatically get access to SXA's implementation of Queryable Datasource and it supports not only what yours do, but additionally comes with a lot of predefined tokens you can make use of.

For information, see: Query Tokens in SXA And additionally, for a cheat sheet of often used queries: SXA tokens for datasource queries

As far as I can tell, you won't even have to do anything with your existing query: datasources, they should be compatible with the SXA logic.

Be careful you don't use the SXA tokens on non-SXA sites. They rely on SXA logic to resolve and would not work. Regular query: however, will.

1
  • Thanks a lot for your answer.
    – arjunan
    May 12, 2019 at 10:52

Your Answer

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

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