From 78e5ed5a0d7aecb191d347ed3c5663fb6544f575 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis Date: Tue, 21 Nov 2023 12:27:45 +0100 Subject: [PATCH 01/15] Draft "Customize search sorting" --- .../search/config/append_to_services.yaml | 5 +++ .../RandomSortingDefinitionProvider.php | 41 +++++++++++++++++++ .../search/translations/ibexa_search.en.yaml | 1 + .../back_office/search_sorting.md | 7 ++++ mkdocs.yml | 1 + 5 files changed, 55 insertions(+) create mode 100644 code_samples/back_office/search/config/append_to_services.yaml create mode 100644 code_samples/back_office/search/src/Search/SortingDefinition/Provider/RandomSortingDefinitionProvider.php create mode 100644 code_samples/back_office/search/translations/ibexa_search.en.yaml create mode 100644 docs/administration/back_office/search_sorting.md diff --git a/code_samples/back_office/search/config/append_to_services.yaml b/code_samples/back_office/search/config/append_to_services.yaml new file mode 100644 index 0000000000..a72afef25f --- /dev/null +++ b/code_samples/back_office/search/config/append_to_services.yaml @@ -0,0 +1,5 @@ +services: + + App\Search\SortingDefinition\Provider\RandomSortingDefinitionProvider: + tags: + - name: ibexa.search.sorting_definition.provider diff --git a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/RandomSortingDefinitionProvider.php b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/RandomSortingDefinitionProvider.php new file mode 100644 index 0000000000..392488354e --- /dev/null +++ b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/RandomSortingDefinitionProvider.php @@ -0,0 +1,41 @@ +translator = $translator; + } + + public function getSortingDefinitions(): array + { + return [ + new SortingDefinition( + 'random', + $this->translator->trans('sort_definition.random.label'), + [ + new SortClause\Random(), + ], + 400 + ), + ]; + } + + public static function getTranslationMessages(): array + { + return [ + (new Message('sort_definition.random.label', 'ibexa_search'))->setDesc('Shuffle'), + ]; + } +} diff --git a/code_samples/back_office/search/translations/ibexa_search.en.yaml b/code_samples/back_office/search/translations/ibexa_search.en.yaml new file mode 100644 index 0000000000..27ddf8eb55 --- /dev/null +++ b/code_samples/back_office/search/translations/ibexa_search.en.yaml @@ -0,0 +1 @@ +sort_definition.random.label: 'Shuffle' diff --git a/docs/administration/back_office/search_sorting.md b/docs/administration/back_office/search_sorting.md new file mode 100644 index 0000000000..e278003dec --- /dev/null +++ b/docs/administration/back_office/search_sorting.md @@ -0,0 +1,7 @@ +--- +description: Add a "sort by" method to the Back Office search result page. +--- + +- Implements `SortingDefinitionProviderInterface::getSortingDefinitions` +- Implements `TranslationContainerInterface::getTranslationMessages` +- Tag as `ibexa.search.sorting_definition.provider` diff --git a/mkdocs.yml b/mkdocs.yml index b56eb360b3..0ff5be3dd9 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -137,6 +137,7 @@ nav: - Multi-file upload: administration/back_office/multifile_upload.md - Sub-items list: administration/back_office/subitems_list.md - Notifications: administration/back_office/notifications.md + - Customize search sorting: administration/back_office/search_sorting.md - Content management: - Content management: content_management/content_management.md - Content management guide: content_management/content_management_guide.md From f5c4f78ee455646eacaf93bae3a0bf7e233559a5 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis Date: Thu, 23 Nov 2023 11:15:53 +0100 Subject: [PATCH 02/15] Custom Search Sorting: Renew example --- .../search/config/append_to_services.yaml | 2 +- .../RandomSortingDefinitionProvider.php | 41 --------------- .../VersionNoSortingDefinitionProvider.php | 51 +++++++++++++++++++ .../search/translations/ibexa_search.en.yaml | 3 +- 4 files changed, 54 insertions(+), 43 deletions(-) delete mode 100644 code_samples/back_office/search/src/Search/SortingDefinition/Provider/RandomSortingDefinitionProvider.php create mode 100644 code_samples/back_office/search/src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php diff --git a/code_samples/back_office/search/config/append_to_services.yaml b/code_samples/back_office/search/config/append_to_services.yaml index a72afef25f..65c5fc9a1e 100644 --- a/code_samples/back_office/search/config/append_to_services.yaml +++ b/code_samples/back_office/search/config/append_to_services.yaml @@ -1,5 +1,5 @@ services: - App\Search\SortingDefinition\Provider\RandomSortingDefinitionProvider: + App\Search\SortingDefinition\Provider\VersionNoSortingDefinitionProvider: tags: - name: ibexa.search.sorting_definition.provider diff --git a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/RandomSortingDefinitionProvider.php b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/RandomSortingDefinitionProvider.php deleted file mode 100644 index 392488354e..0000000000 --- a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/RandomSortingDefinitionProvider.php +++ /dev/null @@ -1,41 +0,0 @@ -translator = $translator; - } - - public function getSortingDefinitions(): array - { - return [ - new SortingDefinition( - 'random', - $this->translator->trans('sort_definition.random.label'), - [ - new SortClause\Random(), - ], - 400 - ), - ]; - } - - public static function getTranslationMessages(): array - { - return [ - (new Message('sort_definition.random.label', 'ibexa_search'))->setDesc('Shuffle'), - ]; - } -} diff --git a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php new file mode 100644 index 0000000000..ec02d26811 --- /dev/null +++ b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php @@ -0,0 +1,51 @@ +translator = $translator; + } + + public function getSortingDefinitions(): array + { + return [ + new SortingDefinition( + 'version_count_asc', + $this->translator->trans('sort_definition.version_count_asc.label'), + [ + new SortClause\CustomField('content_version_no_i', Query::SORT_ASC), + ], + 400 + ), + new SortingDefinition( + 'version_count_desc', + $this->translator->trans('sort_definition.version_count_desc.label'), + [ + new SortClause\CustomField('content_version_no_i', Query::SORT_DESC), + ], + 400 + ), + ]; + } + + public static function getTranslationMessages(): array + { + return [ + (new Message('sort_definition.version_count_asc.label', 'ibexa_search'))->setDesc('Version Count (Less)'), + (new Message('sort_definition.version_count_desc.label', 'ibexa_search'))->setDesc('Version Count (More)'), + ]; + } +} diff --git a/code_samples/back_office/search/translations/ibexa_search.en.yaml b/code_samples/back_office/search/translations/ibexa_search.en.yaml index 27ddf8eb55..59d59a8c2f 100644 --- a/code_samples/back_office/search/translations/ibexa_search.en.yaml +++ b/code_samples/back_office/search/translations/ibexa_search.en.yaml @@ -1 +1,2 @@ -sort_definition.random.label: 'Shuffle' +sort_definition.version_count_asc.label: 'Version Count (Less)' +sort_definition.version_count_desc.label: 'Version Count (More)' \ No newline at end of file From 8e2e3e851aa46b2644dbab060c482fca1ebfd7cf Mon Sep 17 00:00:00 2001 From: Adrien Dupuis Date: Thu, 23 Nov 2023 14:06:16 +0100 Subject: [PATCH 03/15] Custom Search Sorting: Document example --- .../VersionNoSortingDefinitionProvider.php | 16 ++++++------ .../search/translations/ibexa_search.en.yaml | 4 +-- .../back_office/search_sorting.md | 25 ++++++++++++++++--- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php index ec02d26811..1a498798b4 100644 --- a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php +++ b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php @@ -23,20 +23,20 @@ public function getSortingDefinitions(): array { return [ new SortingDefinition( - 'version_count_asc', - $this->translator->trans('sort_definition.version_count_asc.label'), + 'version_number_asc', + $this->translator->trans('sort_definition.version_number_asc.label'), [ new SortClause\CustomField('content_version_no_i', Query::SORT_ASC), ], - 400 + 333 ), new SortingDefinition( - 'version_count_desc', - $this->translator->trans('sort_definition.version_count_desc.label'), + 'version_number_desc', + $this->translator->trans('sort_definition.version_number_desc.label'), [ new SortClause\CustomField('content_version_no_i', Query::SORT_DESC), ], - 400 + 369 ), ]; } @@ -44,8 +44,8 @@ public function getSortingDefinitions(): array public static function getTranslationMessages(): array { return [ - (new Message('sort_definition.version_count_asc.label', 'ibexa_search'))->setDesc('Version Count (Less)'), - (new Message('sort_definition.version_count_desc.label', 'ibexa_search'))->setDesc('Version Count (More)'), + (new Message('sort_definition.version_number_asc.label', 'ibexa_search'))->setDesc('Sort by version number (Less)'), + (new Message('sort_definition.version_number_desc.label', 'ibexa_search'))->setDesc('Sort by version number (More)'), ]; } } diff --git a/code_samples/back_office/search/translations/ibexa_search.en.yaml b/code_samples/back_office/search/translations/ibexa_search.en.yaml index 59d59a8c2f..ed545727cc 100644 --- a/code_samples/back_office/search/translations/ibexa_search.en.yaml +++ b/code_samples/back_office/search/translations/ibexa_search.en.yaml @@ -1,2 +1,2 @@ -sort_definition.version_count_asc.label: 'Version Count (Less)' -sort_definition.version_count_desc.label: 'Version Count (More)' \ No newline at end of file +sort_definition.version_number_asc.label: 'Sort by version number (Less)' +sort_definition.version_number_desc.label: 'Sort by version number (More)' diff --git a/docs/administration/back_office/search_sorting.md b/docs/administration/back_office/search_sorting.md index e278003dec..85e94c8d34 100644 --- a/docs/administration/back_office/search_sorting.md +++ b/docs/administration/back_office/search_sorting.md @@ -2,6 +2,25 @@ description: Add a "sort by" method to the Back Office search result page. --- -- Implements `SortingDefinitionProviderInterface::getSortingDefinitions` -- Implements `TranslationContainerInterface::getTranslationMessages` -- Tag as `ibexa.search.sorting_definition.provider` +# Customize search sorting + +To add an entry to the "Sort by" to the Back Office search result page, create a service implementing the `SortingDefinitionProviderInterface` and tagged `ibexa.search.sorting_definition.provider`. + +The following example class implements `SortingDefinitionProviderInterface::getSortingDefinitions`, and add two definitions to sort by "Version number". +A sorting definition is an identifier, a label, a list of sort clauses, and a priority to position it in the menu. +For the user interface, its also implements `TranslationContainerInterface::getTranslationMessages` to provide two default English translations in the `ibexa_search` namespace. +This example is coded in `src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php`: +``` php hl_lines="22" +[[= include_file('code_samples/back_office/search/src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php') =]] +``` + +Its service definition is appended to `config/services.yaml`: +``` yaml hl_lines="5" +[[= include_file('code_samples/back_office/search/config/append_to_services.yaml') =]] +``` + +Translation file can be extracted with a `translation:extract` command, such as `php bin/console translation:extract en --domain=ibexa_search --dir=src --output-dir=translations` to obtain an `translations/ibexa_search.en.xlf` file. +Or translation file can be manually produced, like the following `translations/ibexa_search.en.yaml`: +``` yaml +[[= include_file('code_samples/back_office/search/translations/ibexa_search.en.yaml') =]] +``` From 122496a1a189c8169604d8016d2c75c750598d3a Mon Sep 17 00:00:00 2001 From: Adrien Dupuis Date: Thu, 23 Nov 2023 14:57:26 +0100 Subject: [PATCH 04/15] Custom Search Sorting: Renew example SortClause\CustomField is not covered by legacy search engine and may differ from Solr to Elasticsearch --- .../search/config/append_to_services.yaml | 2 +- ...hp => SectionNameSortingDefinitionProvider.php} | 14 +++++++------- .../search/translations/ibexa_search.en.yaml | 4 ++-- docs/administration/back_office/search_sorting.md | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) rename code_samples/back_office/search/src/Search/SortingDefinition/Provider/{VersionNoSortingDefinitionProvider.php => SectionNameSortingDefinitionProvider.php} (61%) diff --git a/code_samples/back_office/search/config/append_to_services.yaml b/code_samples/back_office/search/config/append_to_services.yaml index 65c5fc9a1e..597c55245b 100644 --- a/code_samples/back_office/search/config/append_to_services.yaml +++ b/code_samples/back_office/search/config/append_to_services.yaml @@ -1,5 +1,5 @@ services: - App\Search\SortingDefinition\Provider\VersionNoSortingDefinitionProvider: + App\Search\SortingDefinition\Provider\SectionNameSortingDefinitionProvider: tags: - name: ibexa.search.sorting_definition.provider diff --git a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php similarity index 61% rename from code_samples/back_office/search/src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php rename to code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php index 1a498798b4..6175ac3ca6 100644 --- a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php +++ b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php @@ -10,7 +10,7 @@ use JMS\TranslationBundle\Translation\TranslationContainerInterface; use Symfony\Contracts\Translation\TranslatorInterface; -final class VersionNoSortingDefinitionProvider implements SortingDefinitionProviderInterface, TranslationContainerInterface +final class SectionNameSortingDefinitionProvider implements SortingDefinitionProviderInterface, TranslationContainerInterface { private TranslatorInterface $translator; @@ -24,17 +24,17 @@ public function getSortingDefinitions(): array return [ new SortingDefinition( 'version_number_asc', - $this->translator->trans('sort_definition.version_number_asc.label'), + $this->translator->trans('sort_definition.section_name_asc.label'), [ - new SortClause\CustomField('content_version_no_i', Query::SORT_ASC), + new SortClause\SectionName(Query::SORT_ASC), ], 333 ), new SortingDefinition( 'version_number_desc', - $this->translator->trans('sort_definition.version_number_desc.label'), + $this->translator->trans('sort_definition.section_name_desc.label'), [ - new SortClause\CustomField('content_version_no_i', Query::SORT_DESC), + new SortClause\SectionName(Query::SORT_DESC), ], 369 ), @@ -44,8 +44,8 @@ public function getSortingDefinitions(): array public static function getTranslationMessages(): array { return [ - (new Message('sort_definition.version_number_asc.label', 'ibexa_search'))->setDesc('Sort by version number (Less)'), - (new Message('sort_definition.version_number_desc.label', 'ibexa_search'))->setDesc('Sort by version number (More)'), + (new Message('sort_definition.section_name_asc.label', 'ibexa_search'))->setDesc('Sort by section A-Z'), + (new Message('sort_definition.section_name_desc.label', 'ibexa_search'))->setDesc('Sort by section Z-A'), ]; } } diff --git a/code_samples/back_office/search/translations/ibexa_search.en.yaml b/code_samples/back_office/search/translations/ibexa_search.en.yaml index ed545727cc..33d4cb3196 100644 --- a/code_samples/back_office/search/translations/ibexa_search.en.yaml +++ b/code_samples/back_office/search/translations/ibexa_search.en.yaml @@ -1,2 +1,2 @@ -sort_definition.version_number_asc.label: 'Sort by version number (Less)' -sort_definition.version_number_desc.label: 'Sort by version number (More)' +sort_definition.section_name_asc.label: 'Sort by section A-Z' +sort_definition.section_name_desc.label: 'Sort by section Z-A' diff --git a/docs/administration/back_office/search_sorting.md b/docs/administration/back_office/search_sorting.md index 85e94c8d34..a3c374f1db 100644 --- a/docs/administration/back_office/search_sorting.md +++ b/docs/administration/back_office/search_sorting.md @@ -6,12 +6,12 @@ description: Add a "sort by" method to the Back Office search result page. To add an entry to the "Sort by" to the Back Office search result page, create a service implementing the `SortingDefinitionProviderInterface` and tagged `ibexa.search.sorting_definition.provider`. -The following example class implements `SortingDefinitionProviderInterface::getSortingDefinitions`, and add two definitions to sort by "Version number". -A sorting definition is an identifier, a label, a list of sort clauses, and a priority to position it in the menu. -For the user interface, its also implements `TranslationContainerInterface::getTranslationMessages` to provide two default English translations in the `ibexa_search` namespace. -This example is coded in `src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php`: +The following example class implements `SortingDefinitionProviderInterface::getSortingDefinitions`, and add two definitions to sort by section name. +A sorting definition is an identifier, a menu label, a list of [Content Search's Sort Clauses](sort_clause_reference.md#sort-clauses), and a priority to position it in the menu. +For the menu label, its also implements `TranslationContainerInterface::getTranslationMessages` to provide two default English translations in the `ibexa_search` namespace. +This example is coded in `src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php`: ``` php hl_lines="22" -[[= include_file('code_samples/back_office/search/src/Search/SortingDefinition/Provider/VersionNoSortingDefinitionProvider.php') =]] +[[= include_file('code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php') =]] ``` Its service definition is appended to `config/services.yaml`: From 31d6c7f179c371718fff382cec9a5976f5f00f35 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis Date: Fri, 24 Nov 2023 10:00:32 +0100 Subject: [PATCH 05/15] search_sorting.md: Custom Sort Clauses too --- docs/administration/back_office/search_sorting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/administration/back_office/search_sorting.md b/docs/administration/back_office/search_sorting.md index a3c374f1db..6926fe8c93 100644 --- a/docs/administration/back_office/search_sorting.md +++ b/docs/administration/back_office/search_sorting.md @@ -7,7 +7,7 @@ description: Add a "sort by" method to the Back Office search result page. To add an entry to the "Sort by" to the Back Office search result page, create a service implementing the `SortingDefinitionProviderInterface` and tagged `ibexa.search.sorting_definition.provider`. The following example class implements `SortingDefinitionProviderInterface::getSortingDefinitions`, and add two definitions to sort by section name. -A sorting definition is an identifier, a menu label, a list of [Content Search's Sort Clauses](sort_clause_reference.md#sort-clauses), and a priority to position it in the menu. +A sorting definition is an identifier, a menu label, a list of [Content Search's Sort Clauses](sort_clause_reference.md#sort-clauses), even [custom ones](create_custom_sort_clause.md), and a priority to position it in the menu. For the menu label, its also implements `TranslationContainerInterface::getTranslationMessages` to provide two default English translations in the `ibexa_search` namespace. This example is coded in `src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php`: ``` php hl_lines="22" From f516ebc701d6cc2532cd53eb2ff96540e3844d77 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:55:25 +0100 Subject: [PATCH 06/15] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adam Wójs --- .../Provider/SectionNameSortingDefinitionProvider.php | 8 ++++---- docs/administration/back_office/search_sorting.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php index 6175ac3ca6..04cdecaded 100644 --- a/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php +++ b/code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php @@ -23,7 +23,7 @@ public function getSortingDefinitions(): array { return [ new SortingDefinition( - 'version_number_asc', + 'section_asc', $this->translator->trans('sort_definition.section_name_asc.label'), [ new SortClause\SectionName(Query::SORT_ASC), @@ -31,7 +31,7 @@ public function getSortingDefinitions(): array 333 ), new SortingDefinition( - 'version_number_desc', + 'section_desc', $this->translator->trans('sort_definition.section_name_desc.label'), [ new SortClause\SectionName(Query::SORT_DESC), @@ -44,8 +44,8 @@ public function getSortingDefinitions(): array public static function getTranslationMessages(): array { return [ - (new Message('sort_definition.section_name_asc.label', 'ibexa_search'))->setDesc('Sort by section A-Z'), - (new Message('sort_definition.section_name_desc.label', 'ibexa_search'))->setDesc('Sort by section Z-A'), + (new Message('sort_definition.section_name_asc.label'))->setDesc('Sort by section A-Z'), + (new Message('sort_definition.section_name_desc.label'))->setDesc('Sort by section Z-A'), ]; } } diff --git a/docs/administration/back_office/search_sorting.md b/docs/administration/back_office/search_sorting.md index 6926fe8c93..2d9612ef21 100644 --- a/docs/administration/back_office/search_sorting.md +++ b/docs/administration/back_office/search_sorting.md @@ -4,7 +4,7 @@ description: Add a "sort by" method to the Back Office search result page. # Customize search sorting -To add an entry to the "Sort by" to the Back Office search result page, create a service implementing the `SortingDefinitionProviderInterface` and tagged `ibexa.search.sorting_definition.provider`. +To add an entry to the "Sort by" to the Back Office search result page, create a service implementing the `Ibexa\Contracts\Search\SortingDefinition\SortingDefintionProviderInterface` and tagged `ibexa.search.sorting_definition.provider`. The following example class implements `SortingDefinitionProviderInterface::getSortingDefinitions`, and add two definitions to sort by section name. A sorting definition is an identifier, a menu label, a list of [Content Search's Sort Clauses](sort_clause_reference.md#sort-clauses), even [custom ones](create_custom_sort_clause.md), and a priority to position it in the menu. From d7525866fa8d3a0861222c4e4228a9de0c56f856 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis Date: Tue, 19 Dec 2023 16:00:44 +0100 Subject: [PATCH 07/15] search sorting code sample: move to messages.en.yaml Follows f516ebc701d6cc2532cd53eb2ff96540e3844d77 --- .../translations/{ibexa_search.en.yaml => messages.en.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename code_samples/back_office/search/translations/{ibexa_search.en.yaml => messages.en.yaml} (100%) diff --git a/code_samples/back_office/search/translations/ibexa_search.en.yaml b/code_samples/back_office/search/translations/messages.en.yaml similarity index 100% rename from code_samples/back_office/search/translations/ibexa_search.en.yaml rename to code_samples/back_office/search/translations/messages.en.yaml From 30067c0f76944a9dc95484e08628c2ec0e2c6e17 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis Date: Wed, 14 Feb 2024 18:00:03 +0100 Subject: [PATCH 08/15] search_sorting.md: move to messages.en.yaml Follows d7525866fa8d3a0861222c4e4228a9de0c56f856 --- docs/administration/back_office/search_sorting.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/administration/back_office/search_sorting.md b/docs/administration/back_office/search_sorting.md index 2d9612ef21..573ecb8eea 100644 --- a/docs/administration/back_office/search_sorting.md +++ b/docs/administration/back_office/search_sorting.md @@ -19,8 +19,8 @@ Its service definition is appended to `config/services.yaml`: [[= include_file('code_samples/back_office/search/config/append_to_services.yaml') =]] ``` -Translation file can be extracted with a `translation:extract` command, such as `php bin/console translation:extract en --domain=ibexa_search --dir=src --output-dir=translations` to obtain an `translations/ibexa_search.en.xlf` file. -Or translation file can be manually produced, like the following `translations/ibexa_search.en.yaml`: +Translation file can be extracted with a `translation:extract` command, such as `php bin/console translation:extract en --dir=src --output-dir=translations` to obtain an `translations/ibexa_search.en.xlf` file. +Or translation file can be manually produced, like the following `translations/messages.en.yaml`: ``` yaml -[[= include_file('code_samples/back_office/search/translations/ibexa_search.en.yaml') =]] +[[= include_file('code_samples/back_office/search/translations/messages.en.yaml') =]] ``` From 688d659f7454c27b41e588c39d6cbd63ded31f44 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:06:24 +0100 Subject: [PATCH 09/15] Apply suggestions from code review Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com> --- docs/administration/back_office/search_sorting.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/administration/back_office/search_sorting.md b/docs/administration/back_office/search_sorting.md index 573ecb8eea..ab6d6f7556 100644 --- a/docs/administration/back_office/search_sorting.md +++ b/docs/administration/back_office/search_sorting.md @@ -4,23 +4,23 @@ description: Add a "sort by" method to the Back Office search result page. # Customize search sorting -To add an entry to the "Sort by" to the Back Office search result page, create a service implementing the `Ibexa\Contracts\Search\SortingDefinition\SortingDefintionProviderInterface` and tagged `ibexa.search.sorting_definition.provider`. +To add an entry to the "Sort by" to the Back Office search result page, create a service to implement the `Ibexa\Contracts\Search\SortingDefinition\SortingDefintionProviderInterface` and tag `ibexa.search.sorting_definition.provider`. -The following example class implements `SortingDefinitionProviderInterface::getSortingDefinitions`, and add two definitions to sort by section name. -A sorting definition is an identifier, a menu label, a list of [Content Search's Sort Clauses](sort_clause_reference.md#sort-clauses), even [custom ones](create_custom_sort_clause.md), and a priority to position it in the menu. -For the menu label, its also implements `TranslationContainerInterface::getTranslationMessages` to provide two default English translations in the `ibexa_search` namespace. -This example is coded in `src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php`: +The following example class implements `SortingDefinitionProviderInterface::getSortingDefinitions`, and adds two definitions to sort by section name. +A sorting definition contains an identifier, a menu label, a list of [Content Search's Sort Clauses](sort_clause_reference.md#sort-clauses), including [custom ones](create_custom_sort_clause.md), and a priority to position it in the menu. +It also implements `TranslationContainerInterface::getTranslationMessages` to provide two default English translations in the `ibexa_search` namespace. +The example below is coded in `src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php`: ``` php hl_lines="22" [[= include_file('code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php') =]] ``` -Its service definition is appended to `config/services.yaml`: +The service definition is added to `config/services.yaml`: ``` yaml hl_lines="5" [[= include_file('code_samples/back_office/search/config/append_to_services.yaml') =]] ``` Translation file can be extracted with a `translation:extract` command, such as `php bin/console translation:extract en --dir=src --output-dir=translations` to obtain an `translations/ibexa_search.en.xlf` file. -Or translation file can be manually produced, like the following `translations/messages.en.yaml`: +It can be also created manually, as `translations/messages.en.yaml` file below : ``` yaml [[= include_file('code_samples/back_office/search/translations/messages.en.yaml') =]] ``` From db3349431ca36de50b60924b84c4c592b4cc89d9 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Tue, 5 Mar 2024 14:01:40 +0100 Subject: [PATCH 10/15] Update docs/administration/back_office/search_sorting.md --- docs/administration/back_office/search_sorting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/administration/back_office/search_sorting.md b/docs/administration/back_office/search_sorting.md index ab6d6f7556..3829d0774c 100644 --- a/docs/administration/back_office/search_sorting.md +++ b/docs/administration/back_office/search_sorting.md @@ -4,7 +4,7 @@ description: Add a "sort by" method to the Back Office search result page. # Customize search sorting -To add an entry to the "Sort by" to the Back Office search result page, create a service to implement the `Ibexa\Contracts\Search\SortingDefinition\SortingDefintionProviderInterface` and tag `ibexa.search.sorting_definition.provider`. +You can customize the **Sort by** menu in the Back Office search result page. To do so, create a service implementing the `Ibexa\Contracts\Search\SortingDefinition\SortingDefintionProviderInterface` and tag it `ibexa.search.sorting_definition.provider`. The following example class implements `SortingDefinitionProviderInterface::getSortingDefinitions`, and adds two definitions to sort by section name. A sorting definition contains an identifier, a menu label, a list of [Content Search's Sort Clauses](sort_clause_reference.md#sort-clauses), including [custom ones](create_custom_sort_clause.md), and a priority to position it in the menu. From 5527c36956be0e2296ad36fbdfb8b6386afec4dc Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Tue, 5 Mar 2024 14:03:49 +0100 Subject: [PATCH 11/15] =?UTF-8?q?search=5Fsorting.md=20=E2=86=92=20customi?= =?UTF-8?q?ze=5Fsearch=5Fsorting.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{search_sorting.md => customize_search_sorting.md} | 0 mkdocs.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename docs/administration/back_office/{search_sorting.md => customize_search_sorting.md} (100%) diff --git a/docs/administration/back_office/search_sorting.md b/docs/administration/back_office/customize_search_sorting.md similarity index 100% rename from docs/administration/back_office/search_sorting.md rename to docs/administration/back_office/customize_search_sorting.md diff --git a/mkdocs.yml b/mkdocs.yml index d9b82d2f26..9370fa5d85 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -145,7 +145,7 @@ nav: - Multi-file upload: administration/back_office/multifile_upload.md - Sub-items list: administration/back_office/subitems_list.md - Notifications: administration/back_office/notifications.md - - Customize search sorting: administration/back_office/search_sorting.md + - Customize search sorting: administration/back_office/customize_search_sorting.md - Content management: - Content management: content_management/content_management.md - Content management guide: content_management/content_management_guide.md From 64a548b640d2fd6d15c96652d92b18a8923651cc Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:43:17 +0200 Subject: [PATCH 12/15] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tomasz Dąbrowski <64841871+dabrt@users.noreply.github.com> --- .../back_office/customize_search_sorting.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/administration/back_office/customize_search_sorting.md b/docs/administration/back_office/customize_search_sorting.md index 3829d0774c..a68d5fe9c7 100644 --- a/docs/administration/back_office/customize_search_sorting.md +++ b/docs/administration/back_office/customize_search_sorting.md @@ -4,23 +4,29 @@ description: Add a "sort by" method to the Back Office search result page. # Customize search sorting -You can customize the **Sort by** menu in the Back Office search result page. To do so, create a service implementing the `Ibexa\Contracts\Search\SortingDefinition\SortingDefintionProviderInterface` and tag it `ibexa.search.sorting_definition.provider`. +You can customize the **Sort by** menu in the Back Office search result page, for example, by adding new sort criteria. + +To do it, you must create a service that implements the `Ibexa\Contracts\Search\SortingDefinition\SortingDefinitionProviderInterface` and tag it with`ibexa.search.sorting_definition.provider`. The following example class implements `SortingDefinitionProviderInterface::getSortingDefinitions`, and adds two definitions to sort by section name. -A sorting definition contains an identifier, a menu label, a list of [Content Search's Sort Clauses](sort_clause_reference.md#sort-clauses), including [custom ones](create_custom_sort_clause.md), and a priority to position it in the menu. +A sorting definition contains an identifier, a menu label, a list of content search Sort Clauses, which could be either [default](sort_clause_reference.md#sort-clauses) or [custom](create_custom_sort_clause.md), and a priority value to position them in the menu. It also implements `TranslationContainerInterface::getTranslationMessages` to provide two default English translations in the `ibexa_search` namespace. -The example below is coded in `src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php`: + +Create the `src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php` file: + ``` php hl_lines="22" [[= include_file('code_samples/back_office/search/src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionProvider.php') =]] ``` -The service definition is added to `config/services.yaml`: +Then add a service definition to `config/services.yaml`: + ``` yaml hl_lines="5" [[= include_file('code_samples/back_office/search/config/append_to_services.yaml') =]] ``` -Translation file can be extracted with a `translation:extract` command, such as `php bin/console translation:extract en --dir=src --output-dir=translations` to obtain an `translations/ibexa_search.en.xlf` file. -It can be also created manually, as `translations/messages.en.yaml` file below : +You can extract a translation file with the `translation:extract` command, for example, `php bin/console translation:extract en --dir=src --output-dir=translations` to obtain the `translations/ibexa_search.en.xlf` file. +You could also create it manually, as `translations/messages.en.yaml` file with the following contents: + ``` yaml [[= include_file('code_samples/back_office/search/translations/messages.en.yaml') =]] ``` From 59dbadb329bd0a53afe16c8d4e6b6e258b3d61a1 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Thu, 18 Apr 2024 09:23:03 +0200 Subject: [PATCH 13/15] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marek Nocoń --- docs/administration/back_office/customize_search_sorting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/administration/back_office/customize_search_sorting.md b/docs/administration/back_office/customize_search_sorting.md index a68d5fe9c7..d1c8395082 100644 --- a/docs/administration/back_office/customize_search_sorting.md +++ b/docs/administration/back_office/customize_search_sorting.md @@ -6,7 +6,7 @@ description: Add a "sort by" method to the Back Office search result page. You can customize the **Sort by** menu in the Back Office search result page, for example, by adding new sort criteria. -To do it, you must create a service that implements the `Ibexa\Contracts\Search\SortingDefinition\SortingDefinitionProviderInterface` and tag it with`ibexa.search.sorting_definition.provider`. +To do it, you must create a service that implements the `Ibexa\Contracts\Search\SortingDefinition\SortingDefinitionProviderInterface` and tag it with `ibexa.search.sorting_definition.provider`. The following example class implements `SortingDefinitionProviderInterface::getSortingDefinitions`, and adds two definitions to sort by section name. A sorting definition contains an identifier, a menu label, a list of content search Sort Clauses, which could be either [default](sort_clause_reference.md#sort-clauses) or [custom](create_custom_sort_clause.md), and a priority value to position them in the menu. From cc4a2df8cfe1c3020485ad7fc44d20bf52f7d984 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Fri, 19 Apr 2024 09:47:20 +0200 Subject: [PATCH 14/15] customize_search_sorting.md: Fix include_file & hl_lines after merge --- .../back_office/search/config/append_to_services.yaml | 2 +- docs/administration/back_office/customize_search_sorting.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/code_samples/back_office/search/config/append_to_services.yaml b/code_samples/back_office/search/config/append_to_services.yaml index 40382b3c1a..d696ba4c7a 100644 --- a/code_samples/back_office/search/config/append_to_services.yaml +++ b/code_samples/back_office/search/config/append_to_services.yaml @@ -29,4 +29,4 @@ services: App\Search\SortingDefinition\Provider\SectionNameSortingDefinitionProvider: tags: - - name: ibexa.search.sorting_definition.provider + - name: ibexa.search.sorting_definition.provider diff --git a/docs/administration/back_office/customize_search_sorting.md b/docs/administration/back_office/customize_search_sorting.md index d1c8395082..5978eb0430 100644 --- a/docs/administration/back_office/customize_search_sorting.md +++ b/docs/administration/back_office/customize_search_sorting.md @@ -21,7 +21,9 @@ Create the `src/Search/SortingDefinition/Provider/SectionNameSortingDefinitionPr Then add a service definition to `config/services.yaml`: ``` yaml hl_lines="5" -[[= include_file('code_samples/back_office/search/config/append_to_services.yaml') =]] +services: + #… +[[= include_file('code_samples/back_office/search/config/append_to_services.yaml', 29, 32) =]] ``` You can extract a translation file with the `translation:extract` command, for example, `php bin/console translation:extract en --dir=src --output-dir=translations` to obtain the `translations/ibexa_search.en.xlf` file. From af6054c663be44803cc0fc3856d5ddd8e9c2f2dc Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Fri, 19 Apr 2024 09:55:08 +0200 Subject: [PATCH 15/15] customize_search_suggestion.md: Fix include_file lines --- docs/administration/back_office/customize_search_suggestion.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/administration/back_office/customize_search_suggestion.md b/docs/administration/back_office/customize_search_suggestion.md index ae74dac290..0478a0bf33 100644 --- a/docs/administration/back_office/customize_search_suggestion.md +++ b/docs/administration/back_office/customize_search_suggestion.md @@ -139,7 +139,7 @@ To be present, this wrapping node template must be added to the `global-search-a ``` yaml services: #… -[[= include_file('code_samples/back_office/search/config/append_to_services.yaml', 22, 28) =]] +[[= include_file('code_samples/back_office/search/config/append_to_services.yaml', 21, 28) =]] ``` The template for the product suggestion item follows, named `templates/themes/admin/ui/global_search_autocomplete_product_item.html.twig`: