1. Fabrik 3.5.2 is now available to download. Read the blog for highlights about this release.

    As always, please back up your site prior to updating and if possible test in a dev environment first.

    Also, our 3.5.1 package file was hacked, the effected dates were 1/15/2017 - 1/17/2017. If during those days you downloaded the 3.5.1 package file from the JED or our site download page, please re-install the package with a fresh copy or upgrade to Fabrik 3.5.2. Github downloads were not effected.

JLayouts

Jun 29, 2016
JLayouts
  • Migration to using JLayouts is currently a work in progress towards a release of Fabrik 3.4

    Joomla's JLayouts system allows you to override specific parts of a page's HTML. In essence it separates out the HTML for an element into a separate JLayout php file, separating function from form, and making it easy to tweak the HTML of each element and ensuring that elements are rendered consistently. Fabrik is working towards rendering most of the front-end HTML with JLayouts. For example, this will allow you to create a custom look for all of Fabrik's <select> dropdowns, or alter the way a list filter is shown.

    Joomla searches for a layout file in a series of folders. For example the button element's layouts are searched for in the following folders:
    1. /templates/{current-joomla-template}/html/layouts/com_fabrik
    2. /templates/{current-joomla-template}/html/layouts
    3. /layouts
    4. /plugins/fabrik_element/button/layouts
    5. /components/com_fabrik/layouts
    Fabrik provides its default layout in either /plugins/fabrik_element/button/layouts or components/com_fabrik/layouts.
    Fabrik default layout is based on Joomla's Bootstrap2 (Nov 2015). If you are running a Bootstrap3 template you can use https://github.com/Fabrik/bootstrap3-jlayouts to override the Bootstrap2 settings.

    If you copied the layout file into any one of the first three locations, and modified it, you would see those modifications rendered on the site when you view the button.


    Layout file names(top)

    Our files are named in a very specific to avoid potential clashes with other layouts:

    fabrik-{plugin}-{type}-{location}-{moreinfo}.php

    Element labels(top)

    The default layout for the element label is components/com_fabrik/layouts/element/fabrik-element-label.php

    Current status(top)

    As of 17 September 2015, the following elements have been converted to JLayouts in Github (or at least these elements have JLayout files which Rob says are the indicator of having been converted):

    • Access
    • Attending
    • Birthday
    • Button
    • Calc
    • Captcha
    • Cascading Drop Down
    • Colour Picker
    • Database Join
    • Date
    • Digital Signature
    • Display
    • Dropdown
    • Facebook Activity Feed
    • Facebook Comment
    • Facebook Like
    • Facebook Likebox
    • Facebook Recommendations
    • Field
    • File Upload
    • Folder
    • Google Map
    • Google-ometer
    • Image
    • Internal Id
    • IP
    • JS Periodical
    • Link
    • Notes
    • Password
    • Picklist
    • Radio Button
    • Rating
    • Slider
    • Spotify
    • Text Area
    • Thumbs
    • Time
    • Timer
    • Timestamp
    • User
    • User Group
    • View Level
    • Yes / No
    • Youtube

    whilst the following elements remain to be converted:

    • Checkbox
    • Count
    • Tags

    Overriding an JLayout for all elements(top)

    You will need to create a folder in your active Joomla! template directory:
    /templates/{current-joomla-template}/html/layouts/com_fabrik/element/

    Then copy the JLayout file from plugins/fabrik_element/{elements_plugin}/layouts/{layout_file}

    Overriding an element JLayout for a specific element(top)


    You will need to create a folder in your active Joomla! template directory:
    /templates/{current-joomla-template}/html/layouts/com_fabrik/element/{tablename___elementname}

    Replace {tablename___elementname} with your element's full name. Then copy the JLayout file from plugins/fabrik_element/{elements_plugin}/layouts/{layout_file}

    Example(top)


    Lets say you have a dropdown element, full element name 'table___age_range', which has a list filter set up to render as a checkbox list, but rather than showing the standard checkbox list you want to show a series of bootstrap buttons.

    First make a jLayout folder in your current template for the age_range element:
    /templates/{current-joomla-template}/html/layouts/com_fabrik/elements/table___age_range

    The standard checkbox filter jLayout file is found in :

    components/com_fabrik/layouts/list/filter/fabrik-filter-checkbox.php

    ... which you can either copy and modify, or simply override with new code, in your newly created jLayout folder. In the case of list filter layouts, the name of the file needs to be changed to fabrik-element-[elementtype]-list-filter-[filtertype].php, so in this case the name would be fabrik-element-dropdown-list-filter-checkbox.php.

    In order to render as bootstrap buttons, you would use this code:

    PHP:

    <?php
    defined('JPATH_BASE') or die;

    $d = $displayData;

    ?>

    <div class="btn-group" data-toggle="buttons">
        <?php for ($i = 0; $i < count($d->values); $i++) :
            $v       = $d->values[$i];
            $checked = in_array($v, $d->default) ? 'checked="checked"' : '';
            $active  = in_array($v, $d->default) ? 'active' : '';
            ?>
            <label class="btn btn-default <?php echo $active; ?>">
                <input type="checkbox" value="<?php echo $v; ?>" <?php echo $checked; ?> name="<?php echo $d->name; ?>[]" / ><?php echo $d->labels[$i]; ?>
            </label>
            <?php
        endfor;
        ?>
    </div>
     
    Save the file and now your checkbox filter will be rendered as a bootstrap button group.

    Note: the checkbox element already overrides the checkbox filter, so in this case you need to copy the file:
    plugins/fabrik_element/checkbox/layouts/fabrik-element-radiobutton-list-filter-checkbox.php into your new folder.

    List Layouts(top)


    We are gradually converting components of the List display to layouts. For example, you can now override the pagination links and footer. This can be done either globally, by copying one of the files in ...

    /components/com_fabrik/layouts/pagination

    ... to ...

    /templates/{current-joomla-template}/html/layouts/com_fabrik/pagination

    ... or for a specific list, to ...

    /templates/{current-joomla-template}/html/layouts/com_fabrik/list_X/pagination

    ... where X is the numeric ID of your list, like list_7, and edit the file (like fabrik-pagination-footer.php) to suit.

    ... or ...

    ./components/com_fabrik/views/list/tmpl/<yourtemplate>/layouts

    Form Layouts(top)


    Essentially the same as list layouts. See available layouts in /components/com_fabrik/layouts/form
Gruber, vaguemind and rexluther like this.