FooBar Table

Categories

Component ID

2385235

Component name

FooBar Table

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

1909

Component created

Component changed

Component body

FooBar Table duplicates standard table theme and adds two things.

  1. Lets you render tables with <tfoot> tag using theme():
    Element declared like this
    $build['mytable'] = array(
      '#theme' => 'table',
      '#header' => array('head1', 'head2'),
      '#footer' => array('foot1', 'foot2'),
      '#rows' => array(array(1, 2), array(3, 4)),
    );
    

    Will be rendered like this:

    <table class="sticky-enabled">
        <thead>
            <tr><th>head1</th><th>head2</th></tr>
        </thead>
        <tfoot>
            <tr><td>foot1</td><td>foot2</td></tr>
        </tfoot>
        <tbody>
            <tr class="odd"><td>1</td><td>2</td></tr>
            <tr class="even"><td>3</td><td>4</td></tr>
        </tbody>
    </table>
  2. Adds javascript sorting for your table.
    To use javascript sorting you need to install Libraries module, create "jquery.tablesorter" folder in you libraries folder, and put jquery.tablesorter.min.js there.
    Setting 'jsorted' to TRUE enables javascript sorting of the table.
    $build['mytable'] = array(
      '#theme' => 'table',
      '#header' => array(
        'head1', 
        array('data' => 'head2', 'sort' => 'asc'),
        array('data' => 'head3', 'sorter' => FALSE),
       ),
       '#footer' => array('foot1', 'foot2', 'foot3'),
       '#rows' => array(array(4, 2, 3), array(1, 5, 6)),
       '#jsorted' => TRUE,
    );
    

    So this element will be rendered as a table sorted by second column with click handlers attached to header cells and sorting by third column disabled.

    If you don't want no "overhead" related to attaching additional javascript files, just don't set 'jsorted' to TRUE and you will get nice table with footer and no javascript sorting.

You can also keep 'table' theme as is in the core and use 'foobartable' when theming ('#theme' => 'foobartable') with the same result as described above.
Use module's settings page to select one of these options (by default 'table' theme is replaced)

No neat css styles for tables are currently provided by this module but you can try styles available at jquery.tablesorter site.