-
Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.Dismiss Notice
Alphabetical Filter
-
Contents
Fabrik 3.1 (top)
Edit your list and under the layout tab you will see a Tabs section.
Select a field you wish to use as the tab filter, and enter the maximum number of tabs to show. Then press save.
For Fabrik 3.0 or less(top)
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:
PHP:if ($this->showFilters) {
echo $this->loadTemplate('filter');
}?>
PHP:<?php
$element = 'element_test___test';
$url = 'http://'.$_SERVER['HTTP_HOST'].'/FULL/PATH';
$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}?resetfilters=1&".$element."[value]=$l%25&".$element."[condition]=LIKE'>$l</a>";
}
?>
PHP:$element = 'element_test___test';
Also.. to make this work, you will need to replace FULLPATH. This works best with SEF. Then use the url generated for this value.
In case you would like to use this template for more than one list.. The following might help you out. The following assumes the field you are filtering is the same for all lists you will use. To make this work, you have to use menu items that have an alias as the name of your list. SEF is required for this to work.
PHP:<ul class="alphafilter">
<?php
// strip out all stuff and get only the part we need
$uri_parts = explode('?', $_SERVER['REQUEST_URI'], 2);
$url = $uri_parts[0];
$pathparts = explode('/',$url);
$this_list = array_pop($pathparts);
//if popped value is null, there was a trailing slash.. so pop again.
if($this_list == NULL || $this_list == ''){
$this_list = array_pop($pathparts);
}
$element = 'fab_'.$this_list.'___name';
$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 "<li><a href='{$url}?resetfilters=1&".$element."[value]=$l%25&".$element."[condition]=LIKE'>$l</a></li>";
}
?>
<li><a href="<?php echo ($url); ?>">Show ALL</a></li>
</ul>
You can remove the % buy doing a substr on the $filter. On the alpha index, you probably will only have this one filter. The following will not work if you are using more than one filter. It will remove the last char from every filter. This would probably be undesirable. This change is made in the default_filter.php template file.
PHP:
----------------------------------------
An alternative to this is to create a calculated field with the first character of the field you want to select by putting the following in the Calculation box:
PHP:
Note: This needs to load all rows in your table, so you will need to set the number of rows displayed to >= number of rows in the table, and it is not really scalable for more than several hundred rows. - Loading...
XenCarta PRO
© Jason Axelrod from 8WAYRUN.COM