Adding an alphabetical filter

From Fabrik

Jump to: navigation, search

Follow the instructions below to create an alphabetical list of links that filter a table's data by a column first letter.

Make a custom table template: Copy the folder components/com_fabrik/views/tmpl/default and rename it to default_alphafilter

then edit default_alphafilter/default.php and after:


if ($this->showFilters) {
 
    echo $this->loadTemplate('filter'); 
 
}?>

add


<?php
 
$element = 'element_test.test';
 
$url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
 
$letters = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
 
foreach($letters as $l){
 
    echo "<a href='{$url}?advancedFilterContainer[value]=$element like \"{$l}%\" '>$l</a> ";
 
}
 
?>

that will print out a row of links filtering on each letter. The only thing you will need to change is

$element = 'element_test.test';

Replace 'element_test' with your table name and 'test' with the element name.

Personal tools