arambalakjian / dataobjectaspagefilter
该软件包最新版本(dev-master)没有提供许可信息。
过滤使用 DataObjectAsPage 模块创建的 DataObjects - 支持多选和匹配所有过滤器
dev-master
2016-02-16 20:40 UTC
Requires
- silverstripe/cms: 3.1.*
- silverstripe/dataobjectaspage: master-dev
- silverstripe/framework: 3.1.*
Replaces
- silverstripe/dataobjectaspagefilter: *
This package is not auto-updated.
Last update: 2024-09-24 01:46:09 UTC
README
维护者
- Aram Balakjian
所需模块
arambalakjian/dataobjectaspage
分支需求
- 3.1 -> SilverStripe 3.1.x
概述
DOAP 模块的过滤系统。允许您在多对多或一对多关系中将多个类别类型附加到您的 DOAP 上。
非常简单的配置允许您拥有一个多选过滤器(包括链接模式,允许样式化已选/未选),或一个单选过滤器。您还可以选择匹配任意和匹配所有。
餐厅类型 是一个单选过滤器,设施 是一个多选过滤器,启用了匹配所有功能
类别 是一个多选过滤器,启用了匹配任意功能
基本使用示例
您的列表页面类
FilteredProductListingPage.php
class FilteredProductListingPage extends FilteredListingPage{ } class FilteredProductListingPage_Controller extends FilteredListingPage_Controller { //Layout template to use to when AJAX is enabled (ignore if AJAX disabled) private static $ajax_template = 'FilteredProductListingPage'; //This needs to know be the Class of the DataObject you want this page to list private static $item_class = 'Product'; //Set the sort for the items (defaults to Created DESC) private static $item_sort = 'Created DESC'; //Disable AJAX filtering and reload the page when filtering (defaults to true) private static $ajax_filter = false; private static $filter_settings = array( 'Categories' => array( 'Title' => 'Choose Category', //Required - Define the Title of the Filter 'ClassName' => 'CategoryClass',//Required - The Class of the category you are filtering by (the one that extends DataObjectAsPageCategory) 'Preposition' => 'in', //Optional - Define the preposition in the filter message, e.g. Products IN x or y category (Defaults to "in") 'MultiSelect' => false, //Optional - Select Multiple options at once (default is true) 'MatchAll' => false //Optional - Match all the multi selected items, i.e. select a Product which has category x AND y. Requires a Many_Many or Has_Many ) ); }
您的 DataObjectAsPage 类
Product.php
class Product extends DataObjectAsPage { //The class of the page which will list this DataObject private static $listing_class = 'ProductListingPage'; //Class Naming (optional but reccomended) private static $plural_name = 'Products'; private static $singular_name = 'Product'; //Category Relation static $many_many = array( 'Categories' => 'ProductCategory' ); }
您的类别类(可以添加任意多个)
ProductCategory.php
class ProductCategory extends DataObjectAsPageCategory { //Listing Page Class private static $listing_page_class = 'FilteredProductListingPage'; //Class Naming (optional but reccomended) private static $singular_name = 'Category'; private static $plural_name = 'Categories'; //Category Relation private static $belongs_many_many = array( 'Product' => 'Product' ); }
模板化
默认情况下,所有过滤器都没有样式。请查看模板文件夹中的示例,以了解如何结构化标记,然后在您的主题文件夹中覆盖这些模板。