Changeset 1786326
- Timestamp:
- 12/13/2017 03:24:44 PM (8 years ago)
- Location:
- aj-csv-to-datatable/trunk
- Files:
-
- 3 edited
-
README.md (modified) (3 diffs)
-
lib/main_class.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
aj-csv-to-datatable/trunk/README.md
r1276226 r1786326 4 4 Tags: data, table, csv, import, datatable 5 5 Requires at least: 4.3.1 6 Tested up to: 4. 3.17 Stable tag: 4. 36 Tested up to: 4.7.5 7 Stable tag: 4.7 8 8 9 9 Import data from a CSV file and display it in a DataTable. … … 21 21 `[aj-csv2dt src=http://e-innoving.com/samples/SacramentocrimeJanuary2006.csv id=datatable_id]` 22 22 23 Save it, just refresh the page and see. Less hassle, all your csv data is inside the DataTable. 23 You 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. 24 24 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 27 Save it, just refresh the page and see. Less hassle, all your csv data is inside a DataTable now. 25 28 26 29 ## Installation … … 55 58 ## Changelog 56 59 60 ### 1.1 61 * Added options to disable DataTable searching, pagination, sorting and showing of bInfo. 62 57 63 ### 1.0 58 64 * First public release. -
aj-csv-to-datatable/trunk/lib/main_class.php
r1276226 r1786326 45 45 'src' => null, // Source file url. 46 46 '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, 47 54 48 55 ); … … 205 212 } 206 213 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 207 234 echo '<script> 208 235 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 .' }); 210 237 }); 211 238 </script> … … 249 276 250 277 // 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 261 291 return $row_classes; 262 292 } -
aj-csv-to-datatable/trunk/readme.txt
r1279447 r1786326 4 4 Tags: data, table, csv, import, datatable 5 5 Requires 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 6 Tested up to: 4.7.5 7 Stable tag: 4.7 10 8 11 Wordpress Plugin to import data from a CSV file and display i nsidea DataTable.9 Wordpress Plugin to import data from a CSV file and display it in a DataTable. 12 10 13 11 14 12 == Description == 15 13 16 Wordpress Plugin to import data from a CSV file and display inside a DataTable.14 Wordpress Plugin to present a CSV file in a DataTable. This will import data from a CSV file and display in a DataTable. 17 15 18 This is an easy way of importing data from a CSV file and display in a DataTable.19 16 20 Insert following code snippet into any page or post using this shortcode, make sure you use a unique id : 17 == How To Use == 21 18 22 `[aj-csv2dt src=http://your-website.com/file.csv id=unique_id_1]` 19 Insert 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]` 23 22 24 23 Save it, just refresh the page and see. Less hassle, all your csv data is inside the DataTable. 25 24 26 A working example can be found in my blog post [here]27 28 [here]: http://anjanasilva.com/blog/csv-to-datatables-wordpress-plugin29 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-DataTable35 [Click to follow me] : https://twitter.com/anjanasilva36 25 37 26 == Installation == 38 27 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. 28 1. Install and activate the plugin via `WP-Admin > Plugins`. 29 2. Add shortcode to a post or page: `[aj-csv2dt src=http://samplecsvs.s3.amazonaws.com/SacramentocrimeJanuary2006.csv id=datatable_id]`. 52 30 53 31 == Credits == … … 55 33 This plugin utilizes some excellent open source scripts, functions and images whose creators deserve to be recognized. 56 34 57 1. Allan, for the world renowned [DataTables] plugin. 58 1. Shaun Scovil, for inspiring me through his [CSV to Sortable] Plugin. 35 1. Shaun Scovil, for inspiring me through his CSV to Sortable Plugin. 59 36 2. V.Krishn wrote a handy [PHP function] that enables users of PHP < 5.3 to utilize the `str_getcsv()` function that powers this plugin. 60 37 61 38 [CSV to Sortable]: https://wordpress.org/plugins/csv-to-sorttable/ 62 39 [PHP function]: http://github.com/insteps/phputils 63 [DataTables]: https://www.datatables.net/64 40 65 == Frequently Asked Questions ==41 == Common Errors == 66 42 67 43 1. If the datatable misbehaves, this is probably due to an incorrect csv format. In that case, open csv file in excel … … 70 46 == Changelog == 71 47 48 = 1.1 = 49 * Added options to disable DataTable searching, pagination, sorting and showing of bInfo. 50 72 51 = 1.0 = 73 52 * First public release.
Note: See TracChangeset
for help on using the changeset viewer.