Download the PHP package restruct/silverstripe-filterablearchive without Composer

On this page you can find all versions of the php package restruct/silverstripe-filterablearchive. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package silverstripe-filterablearchive

Filterable archive - filter pages by date, tag or category

Maintained by Restruct. If this module saves you time, you can support ongoing maintenance.

This module decorates pages with configurable fields to filter them by. Handy for newsitems & blogs, etc.

Filter items via dropdowns by date (paginated).

Features

Requirements

Installation

Then run dev/build (Silverstripe 5) or sake db:build (Silverstripe 6).

Version compatibility

Branch Module version Silverstripe PHP
main 3.1.x ^5 \|\| ^6 ^8.1
(tags only) 3.0.x ^6 ^8.3
(tags only) 2.0.11 ^4 \|\| ^5 as Silverstripe requires
(tags only) 2.0 - 2.0.10 ^4 as Silverstripe requires

Silverstripe 4 reached end of life in April 2025 and is no longer supported or tested here. Projects still on it can stay on the 2.0.x tags, which remain available.

main is the only maintained line (renamed from master at 3.1.0): it supports every Silverstripe version this module still targets, so there is no separate maintenance branch.

composer.json is the source of truth for exact constraints; this table is a quick reference.

Setup

The module has three extensions: one for the holder page (the page whose children are filtered), one for the holder's controller, and one for the item pages below it. Apply all three, and tell the holder which class its items are and which of their fields holds the date:

Then, in the CMS, enable the date archive, categories and/or tags on the holder page and save/publish it. Categories and tags are created on the holder (or inline, from an item's tag field) and belong to that holder only.

restruct/silverstripe-newsgrid (manage news items from a GridField) applies this module for you when both are installed.

Configuration

All options are set on the holder class. Setting them on the holder class is what the module reads; the defaults come from HolderExtension.

Option Default What it does
managed_object_class Page Class of the items below the holder that are listed and filtered.
managed_object_date_field Created Field of the item that the date archive filters and sorts on (newest first). When it is not Created or LastEdited, items get an edit field for it (a date field for a Date, a date-and-time field for a Datetime).
pagination_active true Show the "items per page" field on the holder.
pagination_control_tab Root.Main CMS tab the holder's filter settings are placed on.
pagination_insert_before not set Name of a field on that tab to place the settings before; ignored if no such field exists.
datearchive_active 'Date' A falsy value (eg false) switches the date archive off for the class; otherwise it is the dropdown's default label.
categories_active 'Categories' Same, for categories.
tags_active 'Tags' Same, for tags.

Per holder page (CMS): the date archive, categories and tags each have an "Enable" checkbox and a label; the date archive has a unit (year, month or day); "items per page" of 0 or empty means no pagination.

A dropdown's label is, in order: the label set on the holder page, the argument passed in the template (see below), the config value above.

Templates

Include these from the holder's template (they run in the controller's scope):

And from an item's template (or inside a loop over items), to show its date, categories and tags:

LinkFilterProps links each category/tag to the holder filtered by it; ShowDateBelow moves the date after them; a DateFieldComment method on the item, if present, is printed next to the date.

The active filter comes from GET parameters (?date=2024-05&cat=press&tag=blue, as the filter form submits them) or from these URLs on the holder: date/2024-05, cat/press, tag/blue. The older archive/2024/05 form still works.

Public API

On the holder (HolderExtension):

Method Returns
getItems() Unfiltered items: managed_object_class children of the holder, newest first. Extensions can change the list through the updateGetItems(&$items) hook.
Categories(), Tags() The holder's categories and tags (FilterProp records).
ArchiveActive(), CategoriesActive(), TagsActive() Whether that filter is switched on by config AND on the page.
ArchiveFilterDropdown($label = null) The date dropdown, or null while the archive is off.
FilterDropdown('cat'\|'tag', $label = null) The category or tag dropdown, or null while that filter is off.

On the holder's controller (HolderControllerExtension):

Method Returns
PaginatedItems() The filtered items, paginated by the holder's "items per page".
getFilteredArchiveItems() The filtered items, unpaginated. A category or tag that does not exist on this holder is ignored.
getFilteredDate(), getFilteredCatSegment(), getFilteredTagSegment() The active filter values (yyyy[-mm[-dd]], or a URL segment), or null.

On an item (ItemExtension):

Method Returns
Categories(), Tags() The item's categories and tags (a many_many through FilterPropRelation).
getHolderPage() The nearest ancestor page with HolderExtension, or null.
getDateField() The item's date as a DB field object (per the holder's managed_object_date_field), or null without a holder.
getRelatedItems() Other items sharing a tag or category with this one (only for filters the holder has on), each listed once.

On a category or tag (FilterProp): Title, URLSegment (derived from the title on write), Link (the holder, filtered by it) and Items() (the pages linked to it).

Running the tests

The module cannot be tested on its own: it needs a host Silverstripe project. Require it there through a Composer path repository with symlink: true - /tests is export-ignore, so a dist or mirrored install contains no tests - add its test namespace to the host's autoload-dev ("Restruct\\SilverStripe\\FilterableArchive\\Tests\\": "vendor/restruct/silverstripe-filterablearchive/tests/"), then:

CI runs the same suite against Silverstripe 5 and 6 on every push; see .github/workflows/ci.yml. Changes per release: CHANGELOG.md.

License

BSD-3-Clause; see LICENSE. Copyright is held by Michael van Schaik (Restruct), Itayi Patrick Chito-voro and Bart van Irsel.


All versions of silverstripe-filterablearchive with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
silverstripe/vendor-plugin Version ^2 || ^3
silverstripe/cms Version ^5 || ^6
silverstripe/tagfield Version ^3 || ^4
symbiote/silverstripe-gridfieldextensions Version ^4 || ^5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package restruct/silverstripe-filterablearchive contains the following files

Loading the files please wait ...