Saturday, February 13, 2021

Sitecore 10 - SXA based query for the droplink to show data from shared and main site based on the SXA token.

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.

Saturday, February 6, 2021

Sitecore 10 - (Sitecore + Octopus ) - How to configure the environment variable, site group setting.




I think this is very common requirement to configure the enviroment variable driven from the octopus, example below


We can configure this in the site gropu and based on sitecore serialization folder structure we will have the .yml file for the above settings as example below

the configuration (yml file) will look like this 


Now, Create a new step in octopus and replace this yml file (Substitute variable in Files) - You can define the wild card syntex like 

#{Path}\src\Project\abc\**\*.yml

Define the variable and value in octopus, in this example for "#{abc.hostname}" and that's it during the deploymnet based on target environment and variable value, Octopus will replace the file and upload into the sitecore, we can use the similar feature for other site settings like analytics key or any sft/ftp configuration etc.