Showing posts with label SXA component. Show all posts
Showing posts with label SXA component. Show all posts

Saturday, April 14, 2018

SXA Add New Language

In this blog, I will show you how to add new language to SXA site.

The first step, as usual, go to the Sitecore setting and add the needed new language,




After that go back to your site and add the language selector component, which is available in the SXA toolbox.



The last step we need to add the language which I added before in the settings to SXA site, then the language will be shown in this component.

To do that:

  1. Select your site under the tenant in the content editor.
  2. Right click on the site.
  3. Choose script menu
  4. Click on add site language,



In the popup dialog choose from the dropdown list "New Language" the second language,


Go back to your language selector and you can see the second language comes and you can select it.

Friday, March 23, 2018

SXA Search tricks - Sitecore

In this post, I will show you one of the tricks of SXA search feature and its Date-Filter component.
SXA search comes with many options and components and one of them is Date-Filter,

To use the search functionality in SXA you have to enable the search config first, SXA search by default is disabled.

Go to path website/app_data/include/z.foundation.overrides and enable the preferred search engine you need, Lucene, Solr or Azure.
After enabling the file make sure to rebuild your indexes.

Date-Filter component provides two filter fields (From Date) and (To Date).



To make this component works there are some steps you need to perform after adding the component:

  1. Set the settings for the Date-Filter: 

These are normal settings of the component, but the important setting is the Facet you want the Date-Filter to filter on.

      2. As you can see I use event date facet which I created this facet in settings folder of the site:



After that, the facet will be available in the dropdown list of the Date-Filter settings.

 3. Select Facet:

so here we connect the search result to filter on the date field:

now add search result component to display the results:



to make the results more specific for the needed items we have to create search scope and if you want sort order, after creating these two items select them in the search result setting boxes:


Go to site settings and create the needed scop:



Sort order is available in different location is available in Data folder  -> Search -> Sort Results:


in each sort order you need to select the facet and the direction of the order, and here we need to select the same facet we created before to sort on it.

this is normal Date-Filter with search results, and this Date-Filter will filter all the events that start between the (From Date) and (To Date), but what if you need all the events start after (From Date) and ends before (To Date),
To make the things clear let me show you an example:
event 1 - start date is 2-3-2018 and end date 6-3-2018.
event 2 - start date is 2-3-2018 and end date 8-3-2018.
if you are using normal Date-Filter settings and you filtering based on start date field between (2-3-2018) - (6-3-2018) the event 1 and event 2 will be showing in the search result. but if you are using two Date-Filters one of them filter on the start date and the other on end date and doing filter between 2-3-2018 and 6-3-2018 only event 2 will showing up in the result.
in this scenario the Date-Filter as is not helping you, the solution here as below:
         1.Add one more Date-Filter for (To Date) field.
         2.Hide the to date text box from the first Date-Filter (From Date).
         3.Hide the from date text box from the new Date-Filter (To Date).
         4.Add new facet (To Date) and assign it to the (To Date) Date-Filter.


First Date-Filter:


Second Date-Filter:



Both Date-Filters:



Create new (To Date) facet contains the (To Date) filed:




Now assign the (To Date) facet to the second Date-Filter component:



In this way, your filter will filter all the events start after (From Date) and ends before (To Date) :)

PS: Don't forget to use same search signature in all search components which belongs to the same search.