Plugin Directory

Changeset 1786326


Ignore:
Timestamp:
12/13/2017 03:24:44 PM (8 years ago)
Author:
anjanasilva
Message:

Added the capability to disable DataTable search, paging, sorting and displaying bInfo if needed. The purpose of this is to show a static looking HTML Table using a CSV.

Location:
aj-csv-to-datatable/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • aj-csv-to-datatable/trunk/README.md

    r1276226 r1786326  
    44Tags: data, table, csv, import, datatable
    55Requires at least: 4.3.1
    6 Tested up to: 4.3.1
    7 Stable tag: 4.3
     6Tested up to: 4.7.5
     7Stable tag: 4.7
    88
    99Import data from a CSV file and display it in a DataTable.
     
    2121`[aj-csv2dt src=http://e-innoving.com/samples/SacramentocrimeJanuary2006.csv id=datatable_id]`
    2222
    23 Save it, just refresh the page and see. Less hassle, all your csv data is inside the DataTable.
     23You can now disable DataTable search, pagination, sorting and displaying of bInfo with the recent 1.1 release. The purpose of this is to render a static looking HTML Table out of a CSV file.
    2424
     25`[aj-csv2dt src=http://e-innoving.com/samples/SacramentocrimeJanuary2006.csv id=datatable_id disable_search=true disable_paging=true disable_binfo=true disable_sorting=true]`
     26
     27Save it, just refresh the page and see. Less hassle, all your csv data is inside a DataTable now.
    2528
    2629## Installation
     
    5558## Changelog
    5659
     60### 1.1
     61* Added options to disable DataTable searching, pagination, sorting and showing of bInfo.
     62
    5763### 1.0
    5864* First public release.
  • aj-csv-to-datatable/trunk/lib/main_class.php

    r1276226 r1786326  
    4545            'src'        => null,   // Source file url.
    4646            'id'         => '',     // Optional value for <table> id attribute.
     47            'disable_search'     => null, // Disable datatable search - false by default.
     48            'disable_paging'     => null,  // Disable datatable pagination - false by default.
     49            'disable_sorting'     => null,  // Disable datatable sorting - false by default.
     50            'disable_binfo'     => null,  // Disable datatable bInfo - false by default.
     51            'unsortable' => null,
     52            'number' => null,
     53            'date' => null,
    4754
    4855        );
     
    205212        }
    206213        echo '</tbody></table>';
     214       
     215        $dtOptionsArray = array();   
     216        if($atts['disable_search'] !== null && $atts['disable_search']){
     217        $dtOptionsArray[] = '"searching" : false';
     218        }
     219        if($atts['disable_paging'] !== null && $atts['disable_paging']){
     220        $dtOptionsArray[] = '"paging" : false';
     221        }
     222        if($atts['disable_sorting'] !== null && $atts['disable_sorting']){
     223        $dtOptionsArray[] = '"ordering" : false';
     224        }
     225        if($atts['disable_binfo'] !== null && $atts['disable_binfo']){
     226        $dtOptionsArray[] = '"bInfo" : false';
     227        }
     228       
     229        $dtOptions = '';
     230        if(count($dtOptionsArray) != 0){
     231            $dtOptions = rtrim(implode(',',$dtOptionsArray), ',');
     232        }
     233       
    207234        echo '<script>
    208235                jQuery(document).ready(function() { 
    209                     jQuery(\'#'.$this->string_to_html_class($atts['id']).'\').DataTable();
     236                    jQuery(\'#'.$this->string_to_html_class($atts['id']).'\').DataTable({ '. $dtOptions .' });
    210237                });
    211238              </script>
     
    249276
    250277        // If 'group' shortcode attribute is set, add a group class to row classes.
    251         $group = intval( $atts['group'] );
    252         if ( $group > 0 && $group <= count( $cols ) ) {
    253 
    254             // Create valid HTML class name based on group cell value.
    255             $group_class = strtolower( strip_tags( $cols[strval( $group - 1 )] ) );
    256             $group_class = $this->string_to_html_class( $group_class );
    257 
    258             // Truncate group class name to a maximum of 25 characters.
    259             $row_classes .= ( empty( $group_class ) ) ? '' : ' ' . substr( $group_class, 0, 25 );
    260         }
     278        if($atts != null && array_key_exists('group', $atts)){
     279            $group = intval( $atts['group'] );
     280            if ( $group > 0 && $group <= count( $cols ) ) {
     281   
     282                // Create valid HTML class name based on group cell value.
     283                $group_class = strtolower( strip_tags( $cols[strval( $group - 1 )] ) );
     284                $group_class = $this->string_to_html_class( $group_class );
     285   
     286                // Truncate group class name to a maximum of 25 characters.
     287                $row_classes .= ( empty( $group_class ) ) ? '' : ' ' . substr( $group_class, 0, 25 );
     288            }
     289        }
     290       
    261291        return $row_classes;
    262292    }
  • aj-csv-to-datatable/trunk/readme.txt

    r1279447 r1786326  
    44Tags: data, table, csv, import, datatable
    55Requires at least: 4.3.1
    6 Tested up to: 4.3.1
    7 Stable tag: 4.3
    8 License: GPLv2 or later
    9 License URI: http://www.gnu.org/licenses/gpl-2.0.html
     6Tested up to: 4.7.5
     7Stable tag: 4.7
    108
    11 Wordpress Plugin to import data from a CSV file and display inside a DataTable.
     9Wordpress Plugin to import data from a CSV file and display it in a DataTable.
    1210
    1311
    1412== Description ==
    1513
    16 Wordpress Plugin to import data from a CSV file and display inside a DataTable.
     14Wordpress Plugin to present a CSV file in a DataTable. This will import data from a CSV file and display in a DataTable.
    1715
    18 This is an easy way of importing data from a CSV file and display in a DataTable.
    1916
    20 Insert following code snippet into any page or post using this shortcode, make sure you use a unique id :
     17== How To Use ==
    2118
    22 `[aj-csv2dt src=http://your-website.com/file.csv id=unique_id_1]`
     19Insert following code snippet into any page or post using this shortcode, make sure you use an unique id :
     20
     21`[aj-csv2dt src=http://e-innoving.com/samples/SacramentocrimeJanuary2006.csv id=datatable_id]`
    2322
    2423Save it, just refresh the page and see. Less hassle, all your csv data is inside the DataTable.
    2524
    26 A working example can be found in my blog post [here]
    27 
    28 [here]: http://anjanasilva.com/blog/csv-to-datatables-wordpress-plugin
    29 
    30 If you are a programmer: Please, read more at GitHub repository: [aj-csv-to-datatable]
    31 
    32 If you are in Twitter and would like to follow me: [Click to follow me]
    33 
    34 [aj-csv-to-datatable]: https://github.com/anjanasilva/AJ-CSV-to-DataTable
    35 [Click to follow me] : https://twitter.com/anjanasilva
    3625
    3726== Installation ==
    3827
    39 1. Install and activate the plugin via `WP-Admin -> Plugins`.
    40 2. Add shortcode to a post or page:
    41 
    42 `[aj-csv2dt src=http://your-website.com/file.csv id=unique_id_1]`
    43 
    44 == Screenshots ==
    45 
    46 1. This is how it looks like screenshot-1.png
    47 
    48 
    49 == Upgrade Notice ==
    50 
    51 1. No upgrade note is available as this is the first public release.
     281. Install and activate the plugin via `WP-Admin > Plugins`.
     292. Add shortcode to a post or page: `[aj-csv2dt src=http://samplecsvs.s3.amazonaws.com/SacramentocrimeJanuary2006.csv id=datatable_id]`.
    5230
    5331== Credits ==
     
    5533This plugin utilizes some excellent open source scripts, functions and images whose creators deserve to be recognized.
    5634
    57 1. Allan, for the world renowned [DataTables] plugin.
    58 1. Shaun Scovil, for inspiring me through his [CSV to Sortable] Plugin.
     351. Shaun Scovil, for inspiring me through his CSV to Sortable Plugin.
    59362. V.Krishn wrote a handy [PHP function] that enables users of PHP < 5.3 to utilize the `str_getcsv()` function that powers this plugin.
    6037
    6138[CSV to Sortable]: https://wordpress.org/plugins/csv-to-sorttable/
    6239[PHP function]: http://github.com/insteps/phputils
    63 [DataTables]: https://www.datatables.net/
    6440
    65 == Frequently Asked Questions ==
     41== Common Errors ==
    6642
    67431. If the datatable misbehaves, this is probably due to an incorrect csv format. In that case, open csv file in excel
     
    7046== Changelog ==
    7147
     48= 1.1 =
     49* Added options to disable DataTable searching, pagination, sorting and showing of bInfo.
     50
    7251= 1.0 =
    7352* First public release.
Note: See TracChangeset for help on using the changeset viewer.