Using Sort inside query parameters
In the present article, we will see how it is possible to define in which order and based on which criteria the images in the search results should appear.
We will make use of an Apex Class Controller and a canvasApp on a Visualforce Page so as to define the sort order inside the query parameters.
Apex Controller
The code snippet below shows the implementation of the Apex Class Controller.
By referring to the above code,
The Sort
Map structure contains two keys:
-
field
- corresponds to the date used to sort the images of the search results. It takes two values:-
created_at
- It is the date on which the image has been uploaded to SharinPix. -
date_taken
- It is the date on which the photo has been captured by a device.
-
-
order
- corresponds to the order in which the images appear in the search results. it takes these values:-
asc
- The images appear from the least recent to the most recent(based on the date defined infield
) -
desc
- The images appear from the most recent to the least recent(based on the date defined infield
)
-
Visualforce Page
The code snippet below illustrates the implementation of the Visualforce Page used to display the SharinPix Image Search.