• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Alphabetical Filter

  • Views Views: 25,146
  • Last updated Last updated:

Navigation

  • Fabrik 3.1​

    list-tabs.png

    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​

    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');
    }?>
    add (Actually, you may add this before or after.. Pretty Much anywhere!!!)
    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>";
    }
    ?>
    This will print out a row of links filtering on each letter. The only thing you will need to change is
    PHP:
    $element = 'element_test___test';
    Replace 'element_test' with your table name and 'test' with the element name.

    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>

    If you have the field in the filter, that you are using for the index, LastName for instance, you will see, after clicking on a letter that the filter for the LastName field will have that letter plus the % char. the % in sql is for WILDCARD.

    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:
    <?php echo substr($filter->element,0,1);?>

    Note: If you would like to still FILTER the results, then you must set resetfilters=1 to 0 or just take it out.

    ----------------------------------------

    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:
    return substr("{placeholder}",0,1);

    You can then set this as a default group-by box for your list and you will then get the ability to open or close each group.

    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.
Back
Top