General

  eZ Systems Website
  Technical documentation
  Editor documentation

This Documentation contains:
 
Technical documentation:



⚠ WARNING ! This documentation is deprecated !

Please go to the current Technical Documentation

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: cosmetic changes

...

By default, the Search Service returns 25 results so, without pagination, the current interface allows you to see view only the 25 Locations. To add the pagination, we need to modify the whole component stack to accept an offset parameter and to use it:

  • the Symfony Controller and the routing configuration should accept an offset parameter and the search query should be build built with it
  • the JavaScript application should also have a route with an offset parameter
  • this offset should be used in the view service when doing the AJAX request
  • the server side code should generate the pagination links and the view should handle those links as the Location links in the previous step.

...

As you can see in the corresponding commit, this is a pure purely Symfony-related task where we have to modify the routing.yml to accept an optional parameter and the action to use it.

...

The new route is very similar to the existing one if we except with the exception of its path property.

Info

The route placeholder concept is documented in the YUI Router component.

...

Depending on which route is matched, an offset parameter might be available. The matched route parameters are available in the request object stored in the request attribute of the view service. So to work with the both the  eZConfList route and the  eZConfListOffset route, the view service has to check if an offset was passed and to use 0 as its default value if none is provided. Once that is done, it can build the URI to use to do the AJAX request. The _load method then becomes:

...

To have working pagination links, the first thing to do is to change the server side code to generate those linksthem. In the corresponding commit, we also define the default limit to at 10 elements. Like for the Location links, the server side code is not really able to generate a link in the JavaScript application, so we have to generate the markup with the offset as a metadata so that the view can recognized recognize and correctly handle those links. So those links get a data-offset attribute with the corresponding offset:

...

After, we just have to change the view code to handle a tap on the next/previous links and when this happens, we can again fire the navigateTo application level event to ask the view service to trigger the navigation but this time to the eZConfListOffset route with the given offset, this is done with:

...

After this change, the pagination should work as expected and you should be able to navigation navigate through the complete list of Locations.

...