http://cyber.law.harvard.edu/cybersecurity/Main_Page
To add this plugin simply link to the extension from your LocalSettings.php:
require_once( "$IP/extensions/DataTables/DataTables.php" );
Or something similar.
- Add the following attributes to the table
data-type-filter="{{{1}}}" data-category-filter="{{{2}}}" data-search-filter="{{{3}}}"
- Create two 1 column tables:
- class='dt_categories'
- class='dt_types'
Which contain a list of categories and types, respectively
- Remove the class
sortable
from your table and replace withdatatable
The PHP is rather straight forward, just basic attribution and loading the necessary JS.
The style was mostly untouched, the custom CSS is used mostly to structure the filter widget.
See the comments.
The basic logic is:
- On DOM ready, check if there are any
.datatable
s, and don't do anything if not - Get a list of categories and types from user-defined 1 column tables
- Remove said tables
- Enable datatables all on tables with class
datatable
- Add the filter widget before the table, bind any changes to trigger the filter functions
- Change all the filter widget options based on the data-attributes configuration, this will trigger the table to update
Copyright President and Fellows of Harvard College, 2013
Licensed under the MIT License.