Filter link generator is an easy-to-use library for generaring human-readable filter links. It can be use for generating links for filter in self-written CMS or frameworks that do not have these features
Use composer to install FilterLinkGenerator into your project
composer require vmexanik/filterlinkgenerator
<?php
use FilterLinkGenerator\FilterLinkGenerator;
$template = "/my-project/{my-filter={\$param}/}";
$data = [
'param' => [
'data' => [
'first_param',
'second_param',
'third_param'
],
'selected' => [
'second_param'
],
'separator' => '_'
]
];
$filterLinks = new FilterLinkGenerator($template, $data);
$generatedLinks = $filterLinks->generateLink()
The $generatedLinks array will contain the generated links for your filter
Array
(
[param] => Array
(
[first_param] => /my-project/my-filter=second_param_first_param/
[second_param] => /my-project/
[third_param] => /my-project/my-filter=second_param_third_param/
)
)