All Projects β†’ toplan β†’ Filter Manager

toplan / Filter Manager

Licence: mit
πŸ”A filter manager help you elegant generate filter url

Labels

Projects that are alternatives of or similar to Filter Manager

Botwall4j
A botwall for Java web applications
Stars: ✭ 41 (-47.44%)
Mutual labels:  filter
Angular1 Async Filter
Angular2 async pipe implemented as Angular 1 filter to handle promises & RxJS observables
Stars: ✭ 59 (-24.36%)
Mutual labels:  filter
Imageviewer
HDR, PFM, DDS, KTX, EXR, PNG, JPG, BMP image viewer and manipulator
Stars: ✭ 71 (-8.97%)
Mutual labels:  filter
Datagrid
Datagrid for Laravel v5
Stars: ✭ 44 (-43.59%)
Mutual labels:  filter
Pandoc Plantuml Filter
Pandoc filter for PlantUML code blocks
Stars: ✭ 51 (-34.62%)
Mutual labels:  filter
Easylistczechandslovak
EasyList Czech and Slovak is an official filter list for AdBlock, Adblock Plus and other ad blockers out there
Stars: ✭ 63 (-19.23%)
Mutual labels:  filter
Washyourmouthoutwithsoap
A list of bad words in many languages.
Stars: ✭ 40 (-48.72%)
Mutual labels:  filter
Queryql
Easily add filtering, sorting, and pagination to your Node.js REST API through your old friend: the query string!
Stars: ✭ 76 (-2.56%)
Mutual labels:  filter
Ubo Youtube
Easier way to exempt your favorite YouTube channels from adblocking.
Stars: ✭ 57 (-26.92%)
Mutual labels:  filter
Sobel
Sobel Filter algorithm in JavaScript.
Stars: ✭ 69 (-11.54%)
Mutual labels:  filter
React Native Gpuimage
GPUImage Component in React Native
Stars: ✭ 45 (-42.31%)
Mutual labels:  filter
Pgo
Go library for PHP community with convenient functions
Stars: ✭ 51 (-34.62%)
Mutual labels:  filter
Obs Streamfx
StreamFX is a plugin for OBS Studio which adds many new effects, filters, sources, transitions and encoders - all for free! Be it 3D Transform, Blur, complex Masking, or even custom shaders, you'll find it all here.
Stars: ✭ 1,128 (+1346.15%)
Mutual labels:  filter
Github Review Filter
Chrome extension to filter files in GitHub code review using glob
Stars: ✭ 42 (-46.15%)
Mutual labels:  filter
Dream3d
Data Analysis program and framework for materials science data analytics, based on the managing framework SIMPL framework.
Stars: ✭ 73 (-6.41%)
Mutual labels:  filter
Depressurizer
A Steam library categorizing tool.
Stars: ✭ 1,008 (+1192.31%)
Mutual labels:  filter
Eloquentfilter
An Eloquent Way To Filter Laravel Models And Their Relationships
Stars: ✭ 1,113 (+1326.92%)
Mutual labels:  filter
Itiriri Async
A library for asynchronous iteration.
Stars: ✭ 78 (+0%)
Mutual labels:  filter
Easygrid
EasyGrid - VanillaJS Responsive Grid
Stars: ✭ 77 (-1.28%)
Mutual labels:  filter
Esa Restlight
ESA Restlight is a lightweight and rest-oriented web framework.
Stars: ✭ 67 (-14.1%)
Mutual labels:  filter

Intro

A filter manager package for the product list filter, help you elegant generate filter url.

δΈ­ζ–‡ζ–‡ζ‘£

demo image

Install

composer require 'toplan/filter-manager:~1.0.4'

Usage

1. The preparatory work

require 'path/to/vendor/autoload.php';
use Toplan\FilterManager\FilterManager as FilterManager;

// params
$paramsArray = [
    'paramName' => 'value',
    ...
]

// create instance by yourself.
$fm = FilterManager::create($paramsArray)->setBlackList(['page']);

//then, render `$fm` value to your template!

Or used in laravel just like this:

Find the providers key in config/app.php and register the FilterManger Service Provider.

    'providers' => array(
        Toplan\FilterManager\FilterManagerServiceProvider::class,
    )

Find the aliases key in config/app.php.

    'aliases' => array(
        'FilterManager' => Toplan\FilterManager\Facades\FilterManager::class,
    )

2. Just enjoy it

use value $fm in template:

<!-- example -->
<li class="item all {{$fm->isActive('gender', FM_SELECT_ALL, 'active', '')}}">
  <a href="{{$fm->url('gender', FM_SELECT_ALL)}}">All</a>
</li>
<li class="item @if($fm->isActive('gender', 'male')) active @endif">
  <a href="{{$fm->url('gender', 'male')}}">Male</a>
</li>
<li class="item @if($fm->isActive('gender', 'female')) active @endif">
  <a href="{{$fm->url('gender', 'female')}}">Female</a>
</li>

or use laravel facade value FilterManager in template:

<!-- example -->
<li class="item all {{FilterManager::isActive('gender', FM_SELECT_ALL, 'active', '')}}">
  <a href="{{FilterManager::url('gender', FM_SELECT_ALL)}}">All</a>
</li>
<li class="item @if(FilterManager::isActive('gender', 'male')) active @endif">
  <a href="{{FilterManager::url('gender', 'male')}}">Male</a>
</li>
<li class="item @if(FilterManager::isActive('gender','female')) active @endif">
  <a href="{{FilterManager::url('gender', 'female')}}">Female</a>
</li>

API

create(array $filters, $baseUrl, $blackList)

create a instance.

  • $filters: this is filters data, required, exp:['gender'=>'male', 'city'=>'beijing']

  • $baseUrl: default value is empty string.

  • $blackList: this is blacklist for filters, default value is [], exp:['pageindex'].

setBlackList(array $list)

set black list for filter.

example:

$fm->setBlackList(['page', 'pageindex']);
//or in laravel
FilterManager::setBlackList(['page', 'pageindex']);

has($filterName)

whether has the character filter, if true will return the value, if don`t return false.

example:

$value = $fm->has('gender');

//or in laravel
$value = FilterManager::has('gender');

isActive($filterName, $filterValue, $trueReturn, $falseReturn)

example:

//in laravel
FilterManager::isActive('gender', 'male');//this will return true or false;

FilterManager::isActive('gender', 'male', 'active', '');//this will return 'active' or '';

url($filterName, $filterValue, $multi, $linkageRemoveFilters, $blackList)

One filter has some values, and every value has a url, this method return a full url string.

  • $filterName: param name, required.

  • $filterValue: param value, default value is FM_SELECT_ALL.

  • $multi: whether to support multiple values? false or true, default value is false.

  • $linkageRemoveFilters:linkage remove the other filter, default value is [].

  • $blackList: temporary blacklist, default value is [].

example:

//in laravel
FilterManager::url('gender', FM_SELECT_ALL);//without gender param

FilterManager::url('gender', 'male', false);//single value

FilterManager::url('cities', 'shanghai', true);
FilterManager::url('cities', 'beijing', true);//multiple values

// One province has many cities, one city has many counties ...,
// If you select 'all province' or one of provinces,
// you should linkage remove the selected cities and counties ...
//
// like this:
// select all province
FilterManager::url('province', FM_SELECT_ALL, false, ['cities', 'counties', ...]);//linkage remove selected cities
// select one province
FilterManager::url('province', 'sichuan', false, ['cities', 'counties', ...]);//linkage remove selected cities
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].