vmexanik/filterlinkgenerator

easily generate links for filter by template

0.0.4 2022-10-25 16:16 UTC

This package is auto-updated.

Last update: 2025-06-17 13:38:43 UTC


README

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

Instalation

Use composer to install FilterLinkGenerator into your project

composer require vmexanik/filterlinkgenerator

Basic Usage

<?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/
        )

)