Scenario - Need to fill the drop link to show the style folder from the global and current site as combined same like when we choose data source through the experience editor for the SXA component, It seems pretty simple, because we have a similar query in the SXA OOTB components, as mentioned below -
query:$site/*[@@name='Data']/*[@@templatename='Promo Folder']|query:$sharedSites/*[@@name='Data']/*[@@templatename='Promo Folder']
When we use the same query in drop link -
Result as an error
ield control has failed to render: Invalid lookup source "query:$site/*[@@name='Data']/*[@@templatename='Promo Folder']|query:$sharedSites/*[@@name='Data']/*[@@templatename='Promo Folder']": End of string expected at position 88..Details
Sitecore.Exceptions.LookupSourceException: Invalid lookup source "query:$site/*[@@name='Data']/*[@@templatename='Promo Folder']|query:$sharedSites/*[@@name='Data']/*[@@templatename='Promo Folder']": End of string expected at position 88.. ---> Sitecore.Data.Query.ParseException: End of string expected at position 88. at Sitecore.Data.Query.QueryParser.Raise(String error) at Sitecore.Data.Query.QueryParser.DoParse(String query) at Sitecore.Data.Query.Query..ctor(String query) at Sitecore.Data.Query.Query.SelectItems(String query, QueryContext contextNode, Database database) at Sitecore.Data.DefaultDatabase.SelectItems(String query) at Sitecore.XA.Foundation.Multisite.Pipelines.GetLookupSourceItems.ExpandVirtualItems.Process(GetLookupSourceItemsArgs args) at (Object , Object ) at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists) at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) at Sitecore.Web.UI.HtmlControls.Data.LookupSources.GetItems(Item current, String source) --- End of inner exception stack trace --- at Sitecore.Web.UI.HtmlControls.Data.LookupSources.GetItems(Item current, String source) at Sitecore.Shell.Applications.ContentEditor.LookupEx.GetItems(Item current) at Sitecore.Shell.Applications.ContentEditor.LookupEx.DoRender(HtmlTextWriter output) at Sitecore.Web.UI.WebControl.Render(HtmlTextWriter output) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at Sitecore.Shell.Applications.ContentEditor.EditorFieldContainer.RenderChildren(HtmlTextWriter writer)
I tried a few more query but it didn't work, Although the individual query was working fine, means reading data from one source using the SXA token but whenever I combined it throws the error
query:$sharedSites/Presentation/Styles|query:$sharedSites/Presentation/Styles
query:$site/Presentation/Styles//*[@@name='Icons']//*, query:$site/Presentation/Styles//*[@@name='Icons']//*
query:$site/*[@@name='Data']/*[@@templatename='Banner Folder']//*and query:$sharedSites/*[@@name='Data']/*[@@templatename='Banner Folder']//*
query:$site/*[@@name='Presentation']/*[@@templatename='Style']|query:$sharedSites/*[@@name='Presentation']/*[@@templatename='Style']
query:$site/*[@@name='Data']/*[@@templatename='Styles']|query:$sharedSites/*[@@name='Data']/*[@@templatename='Styles']
query:$sharedSites/Presentation/Styles//*[@@templatename='Style']
query:$sharedSites/Presentation/Styles//*[@@name='Icons']//*[@@templatename='Styles']
query:$site/*[@@name='Data']/*[@@templatename='Banner Folder']|query:$sharedSites/*[@@name='Data']/*[@@templatename='Banner Folder']
query:$sharedSites/Presentation/Styles//*[@@templatename='Style'] - Working
query:$sites/Presentation/Styles//*[@@name='Icons']//*[@@templatename='Style'] - Working
Solution - After checking the OOTB SXA component query, I found it's using or close with the complete query like below -
query:$site/*[@@name='Data']/*[@@templatename='Promo Folder']|query:$sharedSites/*[@@name='Data']/*[@@templatename='Promo Folder']
I changed the query to below and it worked for me
query:$site/*[@@name='Data']/*[@@templatename='Promo Folder']|$sharedSites/*[@@name='Data']/*[@@templatename='Promo Folder']
Here is the outcome - You can see the second drop link field with the updated query
I hope that will help others.
No comments:
Post a Comment