This documentation is for a version that has reached its End Of Life. Such versions are no longer supported and don't receive security updates. Consider updating to a newer version.
Create custom Sort Clause¶
To create a custom Sort Clause, do the following.
Create Sort Clause class¶
First, add a ScoreSortClause.php
file with the Sort Clause class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Create Sort Clause visitor¶
Then, add a ScoreVisitor
class that implements SortClauseVisitor
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
The supports()
method checks if the implementation can handle the given Sort Clause.
The visit()
method contains the logic that translates Sort Clause information into data understandable by the search engine.
The visit()
method takes the Sort Clause visitor, the Sort Clause itself and the language filter as arguments.
Finally, register the visitor as a service.
Sort Clauses can be valid for both content and Location search.
To choose the search type, use either content
or location
in the tag when registering the visitor as a service:
1 2 3 4 5 |
|
1 2 3 4 5 |
|