Display a filterable collection of pages or dataobjects on a page.
Display a filterable collection of pages or dataobjects on a page.
composer require dynamic/silverstripe-collection
In your config.yml:
Your/Namespace/ExamplePageController:
managed_object: ExampleObject
page_size: 10
extensions:
- Dynamic\Collection\CollectionExtension
Collection will create a search form based on the managed object's $searchable_fields
.
private static $searchable_fields = [
'Title' => [
'title' => 'Name',
],
'Category.ID' => [
'title' => 'Category',
],
];
For advanced setups, you can also create getCustomSearchContext()
on your managed object.
To include a sorting dropdown field, create a getSortOptions()
method on your managed object:
public function getSortOptions()
{
return array(
'Created' => 'Date',
'Title' => 'Name A-Z',
'Title DESC' => 'Name Z-A',
);
}
$CollectionSearchForm
will display the search form.
You have mutliple options to loop through the results in your template:
$Collection
will display a list of all results$PaginatedList
will paginate the results$GroupedList.GroupedBy(CategoryTitle)
will display results grouped by the variable you passSee the docs/en folder.
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem