2017 © Pedro Peláez
 

silverstripe-module silverstripe-filterable

Silverstripe module allowing creation of custom filters through the admin interface and then assigning to an object.

image

i-lateral/silverstripe-filterable

Silverstripe module allowing creation of custom filters through the admin interface and then assigning to an object.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Silverstripe Filterable

Module to allow creation of "Filters" that can be mapped to data objects., (*1)

The idea is that we then add ability to render these filters to front end templates and (eventually) add them to search results., (*2)

At the moment, only the backend mapping is supported by the module, front-end support comming soon..., (*3)

Author

This module is created and maintained by ilateral, (*4)

Contact: morven@i-lateral.com, (*5)

Dependancies

Installation

Install this module either by downloading and adding to:, (*6)

[silverstripe-root]/filterable, (*7)

Then run: dev/build/?flush=all, (*8)

Or alternativly add to your project's composer.json, (*9)

Usage

Once installed, you can setup filters via the "Filters" tab in the CMS., (*10)

Mapping to objects

To be able to add filters to your objects, add the following to your _config.php, (*11)

Filterable::add("YourObjectName", "RelationName");
  • YourObjectName is the name of the object you want to add filters to.
  • RelationName is the name of the relation added to the FilterOption object (for example, "Products").

Filtering on a controller

To be able to see a list of filtered objects from a controller, you need to add FilterableController to your controller classes. You can do this in either of the standard ways:, (*12)

Via config.yml, (*13)

YourController:
  extensions:
    - FilterableController

Via _config.php, (*14)

YouController::add_extension("FilterableController");

Once a controller has been extended, it gains access to a "FilterMenu" and a "filterby" action., (*15)

Filter Menu

The Filter Menu can be loaded into a template using the template variable:, (*16)

$FilterMenu

This generates a menu of available filters and options, (*17)

Filter By

The "filterby" action returns a result set of objects, based on the relations you stipulate via Filterable::add()., (*18)

These results are rendered into a template, you can overwrite this template in several ways., (*19)

  1. Create a template called YourClassName_filterby.ss in your Layout This will allow you to create several different styled filters, depending on the controller., (*20)

  2. Create a template called FilterBy.ss in your Layout directory., (*21)

The Versions

21/01 2016

dev-master

9999999-dev http://github.com/i-lateral/silverstripe-filterable

Silverstripe module allowing creation of custom filters through the admin interface and then assigning to an object.

  Sources   Download

BSD-3-Clause

The Requires

 

filter silverstripe dataobject