Skip to main content
Post Undeleted by Richard Seal
added 1368 characters in body
Source Link
Gatogordo
  • 20.3k
  • 2
  • 39
  • 100

I've implemented a SEO friendly version of a SXA listing page using the search components. What I actually did was creating a custom component that uses the scope defined in SXA to do the search, as well as the pagination from SXA. The output is done with variants so we are reusing lots of SXA stuff.

It's a bit much to show all code here, but lets try to give you the highlights. The pagination part can be found on https://ggullentops.blogspot.com/2018/12/sxa-pagination-on-custom-component.html. The reuse of the scope will be done in the near future..

Pagination

For pagination on a custom component:

  • Your rendering does need rendering parameters. The rendering parameters temlate for your component should inherit IPaginable and IPagination (both from the Feature/Experience Accelerator/Page Content/Rendering Parameters folder
  • The rendering item needs IsPaginationEnabledRendering true as (other) property
  • Your controller needs to derive from PaginableController.
  • Implement the function PaginationConfiguration in the controller to generate a IListPagination. This is the object you can pass to the repository that fetches the data to select the required page.
  • Implement the function OnActionExecuting in the controller to initialize the pagination context ListPaginationContext

Scope

To reuse the scope, note that a scope is actually a rendering parameter. You can read it - will be a string with the guid in it. To get a query based on the scope:

var scopeItem = Sitecore.Context.Database.GetItem(new ID(scope));
var scopeQuery = scopeItem[Constants.ScopeQuery];
var model = SearchStringModel.ParseDatasourceString(scopeQuery);

using (var context = searchContextBuilder.GetSearchContext(indexName))
{
  var query = LinqHelper.CreateQuery<ContentPage>(context, model);

I've implemented a SEO friendly version of a SXA listing page using the search components. What I actually did was creating a custom component that uses the scope defined in SXA to do the search, as well as the pagination from SXA. The output is done with variants so we are reusing lots of SXA stuff.

It's a bit much to show all code here. The pagination part can be found on https://ggullentops.blogspot.com/2018/12/sxa-pagination-on-custom-component.html. The reuse of the scope will be done in the near future..

I've implemented a SEO friendly version of a SXA listing page using the search components. What I actually did was creating a custom component that uses the scope defined in SXA to do the search, as well as the pagination from SXA. The output is done with variants so we are reusing lots of SXA stuff.

It's a bit much to show all code here, but lets try to give you the highlights. The pagination part can be found on https://ggullentops.blogspot.com/2018/12/sxa-pagination-on-custom-component.html. The reuse of the scope will be done in the near future..

Pagination

For pagination on a custom component:

  • Your rendering does need rendering parameters. The rendering parameters temlate for your component should inherit IPaginable and IPagination (both from the Feature/Experience Accelerator/Page Content/Rendering Parameters folder
  • The rendering item needs IsPaginationEnabledRendering true as (other) property
  • Your controller needs to derive from PaginableController.
  • Implement the function PaginationConfiguration in the controller to generate a IListPagination. This is the object you can pass to the repository that fetches the data to select the required page.
  • Implement the function OnActionExecuting in the controller to initialize the pagination context ListPaginationContext

Scope

To reuse the scope, note that a scope is actually a rendering parameter. You can read it - will be a string with the guid in it. To get a query based on the scope:

var scopeItem = Sitecore.Context.Database.GetItem(new ID(scope));
var scopeQuery = scopeItem[Constants.ScopeQuery];
var model = SearchStringModel.ParseDatasourceString(scopeQuery);

using (var context = searchContextBuilder.GetSearchContext(indexName))
{
  var query = LinqHelper.CreateQuery<ContentPage>(context, model);
Mod Converts to Comment
Post Deleted by Richard Seal
Source Link
Gatogordo
  • 20.3k
  • 2
  • 39
  • 100

I've implemented a SEO friendly version of a SXA listing page using the search components. What I actually did was creating a custom component that uses the scope defined in SXA to do the search, as well as the pagination from SXA. The output is done with variants so we are reusing lots of SXA stuff.

It's a bit much to show all code here. The pagination part can be found on https://ggullentops.blogspot.com/2018/12/sxa-pagination-on-custom-component.html. The reuse of the scope will be done in the near future..