PHP code example of jlchassaing / facetbundle

1. Go to this page and download the library: Download jlchassaing/facetbundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jlchassaing / facetbundle example snippets



$facetSearchHelper = $this->container->get('gie.facet.search.helper')
                                     ->init(new FacetConfig('Content types', 
                                                             ContentTypeFacetSearchHelper::class,
                                                             [
                                                            'minCount' => 2,
                                                            'limit' => 5,
                                                            ]),
                                            new FacetConfig('Key Words',
                                                             TagFacetSearchHelper::class,
                                                             [
                                                            'minCount' => 1,
                                                            'limit' => 5,
                                                            ]),
                                            new FacetConfig('custom_date',
                                                            'Publication date'),
                                            new FacetConfig('solr_field',
                                                            'Year',
                                                            ['field' => 'meta_year_date_dt',
                                                             'format' => function($value){
                                                             $date = new \DateTime($value);
                                                             return $date->format('Y');}
                                                            ]),
            ], $request);



 $query = $facetSearchHelper->addQueryFacets($query);

use Gie\FacetBuilder\Pagination\Pagerfanta\ContentSearchAdapter;

$facets = $facetSearchHelper->getFacetsFromPager($pager);

$facets = $facetHelper->getFacetsFromQuery($queryResult);



array:2 [▼
  "Facet Name" => array [▼
    0 => array [▼
      "name" => "Facet Value Name"
      "key" => "facet_generate_key"
      "count" => count 
      "querystring" => "querystring" /* query string to add to the request */
      "selected" => true|false 
    ]
    .../...
  ]
]