chameleon-system-private/item-list-bundle
Base bundle to handle lists with filter/paging/sorting
Requires
- chameleon-system/chameleon-base: ~8.0.0
Suggests
- chameleon-system/elastic-integration-bundle: To use elastic as a source for the list
- 8.47.1
- 8.47.0
- 8.0.x-dev
- 8.0.50
- 8.0.48
- 8.0.46
- 8.0.45
- 8.0.44
- 8.0.43
- 8.0.42
- 8.0.41
- 8.0.40
- 8.0.39
- 8.0.38
- 8.0.37
- 8.0.36
- 8.0.35
- 8.0.34
- 8.0.33
- 8.0.32
- 8.0.31
- 8.0.30
- 8.0.29
- 8.0.28
- 8.0.27
- 8.0.26
- 8.0.25
- 8.0.24
- 8.0.23
- 8.0.22
- 8.0.21
- 8.0.20
- 8.0.19
- 8.0.18
- 8.0.17
- 8.0.16
- 8.0.15
- 8.0.14
- 8.0.13
- 8.0.12
- 8.0.11
- 8.0.10
- 8.0.9
- 8.0.8
- 8.0.7
- 8.0.6
- 8.0.5
- 8.0.4
- 8.0.3
- 8.0.2
- 8.0.1
- 7.1.x-dev
- 7.1.140
- 7.1.139
- 7.1.138
- 7.1.137
- 7.1.136
- 7.1.135
- 7.1.134
- 7.1.133
- 7.1.132
- 7.1.131
- 7.1.130
- 7.1.129
- 7.1.128
- 7.1.127
- 7.1.126
- 7.1.125
- 7.1.124
- 7.1.123
- 7.1.122
- 7.1.121
- 7.1.120
- 7.1.119
- 7.1.118
- 7.1.117
- 7.1.116
- 7.1.115
- 7.1.114
- 7.1.113
- 7.1.112
- 7.1.111
- 7.1.110
- 7.1.109
- 7.1.108
- 7.1.107
- 7.1.106
- 7.1.105
- 7.1.104
- 7.1.103
- 7.1.102
- 7.1.101
- 7.1.100
- 7.1.99
- 7.1.98
- 7.1.97
- 7.1.96
- 7.1.95
- 7.1.94
- 7.1.93
- 7.1.92
- 7.1.91
- 7.1.90
- 7.1.89
- 7.1.88
- 7.1.87
- 7.1.86
- 7.1.85
- 7.1.84
- 7.1.83
- 7.1.82
- 7.1.81
- 7.1.80
- 7.1.79
- 7.1.78
- 7.1.77
- 7.1.76
- 7.1.75
- 7.1.74
- 7.1.73
- 7.1.72
- 7.1.71
- 7.1.70
- 7.1.69
- 7.1.68
- 7.1.67
- 7.1.66
- 7.1.65
- 7.1.64
- 7.1.63
- 7.1.62
- 7.1.61
- 7.1.60
- 7.1.59
- 7.1.58
- 7.1.57
- 7.1.56
- 7.1.55
- 7.1.54
- 7.1.53
- 7.1.52
- 7.1.51
- 7.1.50
- 7.1.49
- 7.1.48
- 7.1.47
- 7.1.46
- 7.1.45
- 7.1.44
- 7.1.43
- 7.1.42
- 7.1.41
- 7.1.40
- 7.1.39
- 7.1.38
- 7.1.37
- 7.1.36
- 7.1.35
- 7.1.34
- 7.1.33
- 7.1.32
- 7.1.31
- 7.1.30
- 7.1.29
- 7.1.28
- 7.1.27
- 7.1.26
- 7.1.25
- 7.1.24
- 7.1.23
- 7.1.22
- 7.1.21
- 7.1.20
- 7.1.19
- 7.1.18
- 7.1.17
- 7.1.16
- 7.0.x-dev
- 7.0.25
- 7.0.24
- 7.0.23
- 7.0.22
- 7.0.21
- 7.0.20
- 7.0.19
- 7.0.18
- 7.0.17
- 7.0.16
- 7.0.15
- dev-main
- dev-66480-paypal-button-integration-wip
- dev-64817-update-tag-manager-bundle
- dev-64992-campaign-tracking-bundle
- dev-65797-paypal-button-integration
- dev-65797-paypal-checkout-7.1.x
README
Bundle provides a module to list, page, sort and filter any content.
Usage Example
To create your own list, follow these steps:
Optional but recommended: Create a Data Model for your list items
Create a List for your Data Models by implementing
\ChameleonSystem\ItemList\Interfaces\ItemListInterface. This class is used to hold the sorted, paged and filtered result of a search.Create a list provider for your content by implementing
\ChameleonSystem\ItemList\Interfaces\ItemListProviderInterface. This class will hold the search/filter/sort and paging logic for your list.Create a new Module for your list by creating a service for
\ChameleonSystem\ItemListBundle\Bridge\Chameleon\Module\ListModuleand registering it in the chameleon module list. Make sure to link the tablechameleon_item_list_configurationto your Module for basic configuration.
Filter
Filter are created in groups. Usually a group of filters is used for one module. To create a group of filter,
you need to define it in your config.yaml under the chameleon_system_item_list attribute. Example:
chameleon_system_item_list:
filter:
-
id: experience
title: my_title_translation_key
group: consultant
view: /filter/consultant-experience.html.twig
-
id: bank
title: bank_title_translation_key
group: consultant
view: /filter/consultant-bank.html.twig
The id attribute is used as a parameter for the filter in the get/post request. You may also use the ID to map the filter
data to some method/service in your item list provider to interpret the filter data.
The group name is passed to your list module so it can automatically pick the filters relevant for it.
The title can be used in each filter as a title for the filter - and should be passed through trans
The view should be used in your list view to render the data of each filter.
The Module will create a FilterDataModel for each filter in your group and pass these (along with the data provided by the user for each filter) to your item provider.
It is your item providers job then, to
- use the data passed to filter the search
- add the filter list back into your
\ChameleonSystem\ItemList\Interfaces\ItemListInterfaceimplementation - along with the available data for each filter.
Please note, that the module assumes, that the filter is rendered as part of the module itself.
The Module will overwrite any filters passed via GET with filters you set via request attributes. This makes it possible to create prefiltered landing pages with custom URLs.
Example:
class MyLandingPageController
{
private ChameleonControllerInterface $mainController;
public function __construct(ChameleonControllerInterface $mainController)
{
$this->mainController = $mainController;
}
public function viewBankSolutions(Request $request, string $experience, string $pagedef): Response
{
$request->attributes->set(ListModule::PARAM_FILTER, [
'experience' => $experience
]);
$request->attributes->set('pagedef', $pagedef);
return $this->mainController->__invoke();
}
}
Sorting
Sorting is defined and used in a similar way as filter.
chameleon_system_item_list:
sort:
-
id: experience
title: my_title_translation_key
group: consultant
-
id: bank
title: bank_title_translation_key
group: consultant
The list of sorting options are selected via the group and made available in the module view as
sortOptions. The active sort id is passed to the view as activeSortId.
The active sort option will be passed to your item provider, where you will need to interpret it.
Paging
Paging can be done via the twig file /list/paging.html.twig. The parameters required when including the paging block
are described in the header of the paging twig.
Example:
{% include "/list/paging.html.twig"
with {
'paging':paging,
'pageParam': constant('ChameleonSystem\\ItemListBundle\\Bridge\\Chameleon\\Module\\ListModule::PARAM_PAGE_NUMBER'),
'filterParameterUrlEncoded': filterParameterUrlEncoded
}
%}
Caching
Please note, that the list currently does not cache. This is intended behaviour, since caching lists is tricky.
If you are able to add caching (even if it is only for the first page of the list), you are encouraged to do so, by
extending the \ChameleonSystem\ItemListBundle\Bridge\Chameleon\Module\ListModule class and implementing the appropriate methods.
Views
You will find example views for the list, filter, paging etc in Resources/views