0

We have a requirement where we need to display the first two news items (sorted by time) and along with it there will be a link to view the rest of the news as well (this is page 1). If they click on the link they will go to a separate page with the same scope and render all the other news (page 2).

Current in the page 1 we have a search result component with the scope mentioned and count as 2, we like to know how we can configure dynamically the link with the same scope.

Should we use some composite rendering to combine both Search result and search box in Page -1. Kindly let us know the best practice for the same in SXA.

Note: we are using facets on page 1 - this information has to be taken into account on page 2.

4
  • I don't understand your problem. If the full results are on another page, that page has a link and you can use that - or what am I missing? – Gatogordo Dec 30 '20 at 11:29
  • yes the full result is in other page, how to link to the other page with the first page scope. e.g in the first page if i am showing latest first two sport related new and it also have link starting ( view all sport news)... which will lead to the another page. – Karthik Raghavan Dec 30 '20 at 11:39
  • Is your "sports news" a fixed page or is that "sports" a facet (filter)? And if fixed, why not have the full page fixed with a scope as well? – Gatogordo Dec 30 '20 at 13:25
  • its not fixed one its a facet.. i want to dynamically add the scope for the link – Karthik Raghavan Dec 30 '20 at 13:42
0

You will not be able to do this completely ootb.

Step one would be to pass the chosen facets on page 1 to page 2. I'm no javascript expert but I'm pretty sure a js developer can do this. When the user clicks the link, some js code could check the facets and attach that data to the fixed part of the url to page 2.

On page 2 however, you can use the same scope as in page 1, but you will need to be able to add the "scope" that came from the facets. This would require some custom coding. You could create a custom search token that you add to the scope in page 2. I explained how to do that in this post: https://ggullentops.blogspot.com/2019/01/extending-sxa-search-query-tokens.html

That custom token should read the facet data from the url (querystring?) as it was passed along and convert that back into SearchStringModels for your queries. I can't tell you exactly how as this relies on your facets and datatypes but the post should get you started.

Tip: start small.. try with one facet and expand when that works.

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.