2017 © Pedro Peláez
 

library chtmltable

Classes for HTML Table

image

meax/chtmltable

Classes for HTML Table

  • Saturday, October 3, 2015
  • by Meax
  • Repository
  • 2 Watchers
  • 0 Stars
  • 12 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Scrutinizer Code Quality Code Coverage Build Status, (*1)

chtmltable

A HTML helper written in PHP to create a html table. Written for Anax-MVC.
First version includes the class SimpleHTMLTable.php and an example file in webroot folder, simplehtmltable.php., (*2)

To install with Composer and Packagist add chtmltable to your composer.json file in Anax., (*3)

"require": {
    "php": ">=5.4",
    "meax/chtmltable": "dev-master"
},

Move the example file simplehtmltable into your Anax installation's webroot folder., (*4)

How to build a table

Method createTable($columns, $data)
Accepts a multiarray $columns representing the header row and the columns of the table.
Accepts a multiarray or object $data which represents the rows of the table., (*5)

Example $columns, (*6)

$columns = array([  
'name' => 'name',   
'label' => 'Name',     
],  
[  
'name' => 'id',     
 'label' => 'Id',    
]);

'name' - a value referring to a key in object or array $data
'label' - the label to be placed in between the , (*7)

tags.

Example $data, (*8)

$data = array(  
1 => [   
'name' => 'Maria',  
'id' => '1' 
],  
2 => [  
'name' => 'Anon',  
'id' => '2'  
],  
);  

Will result in a table:, (*9)

| Name| Id |
| Maria | 1 |
| Anon | 2 |, (*10)

It is possible to create links for all cells in a column according to a linkpattern given in 'linkbase' and 'linkkey'. 'linkbase' is a static base url for the links and 'linkkey' can be defined to locate a key in the array or object $data., (*11)

Example, (*12)

$columns = array([
  'name' => 'fruits',
  'label' => 'Fruits',

],
[
  'name' => 'animals',
  'label' => 'Animals',
  'linkbase' => 'https://en.wikipedia.org/wiki/',
  'linkkey' => 'animals',

],
);

$data = array(
  1 => [
  'fruits' => 'Apple', 
  'animals' => 'Horse' 
   ],
  2 => [
  'fruits' => 'Banana', 
  'animals' => 'Monkey' 
   ],
);

Converting column data

With the help of the method getDisplayVal($val, $displaytype, $format) it is possible to convert values from the array/object $data into another display value. This version supports converting true/false, 1/0, emtpy/not empty into simply "Yes" or "No". It also supports converting a date string into another date format., (*13)

$columns = array([
  'name' => 'date',
  'label' => 'Date',
  'display' => 'convert-datestr',
  'displayformat' => 'Y-m-d',
],
[
  'name' => 'title',
  'label' => 'Title',

],
[
  'name' => 'published',
  'label' => 'Published',
  'display' => 'yes-no',     
],
);

$data = array(
  1 => [
  'date' => '2015-05-15 12:14', 
  'title' => 'A blog post',
  'published' => true,
   ],
  2 => [
  'date' => '2015-05-16 13:15', 
  'title' => 'Another post',
  'published' => false,
   ],
);

Have a look at the example file simplehtmltable.php to see what creating links and converting data looks like., (*14)

The Versions

03/10 2015

dev-master

9999999-dev http://mariajonsson.com

Classes for HTML Table

  Sources   Download

MIT

The Requires

  • php >=5.4

 

html education tables

03/10 2015

v2.0

2.0.0.0 http://mariajonsson.com

Classes for HTML Table

  Sources   Download

MIT

The Requires

  • php >=5.4

 

html education tables

28/09 2015

2.x-dev

2.9999999.9999999.9999999-dev http://mariajonsson.com

Classes for HTML Table

  Sources   Download

MIT

The Requires

  • php >=5.4

 

html education tables

28/09 2015

dev-scrutinizer-patch-4

dev-scrutinizer-patch-4 http://mariajonsson.com

Classes for HTML Table

  Sources   Download

MIT

The Requires

  • php >=5.4

 

html education tables

27/09 2015

dev-scrutinizer-patch-3

dev-scrutinizer-patch-3 http://mariajonsson.com

Classes for HTML Table

  Sources   Download

MIT

The Requires

  • php >=5.4

 

html education tables

26/09 2015

dev-scrutinizer-patch-2

dev-scrutinizer-patch-2 http://mariajonsson.com

Classes for HTML Table

  Sources   Download

MIT

The Requires

  • php >=5.4

 

html education tables

26/09 2015

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1 http://mariajonsson.com

Classes for HTML Table

  Sources   Download

MIT

The Requires

  • php >=5.4

 

html education tables

26/09 2015

v1.1

1.1.0.0 http://mariajonsson.com

Classes for HTML Table

  Sources   Download

MIT

The Requires

  • php >=5.4

 

html education tables

20/09 2015

v1.0

1.0.0.0 http://mariajonsson.com

Classes for HTML Table

  Sources   Download

MIT

The Requires

  • php >=5.4

 

html education tables