0
votes

I am trying to use the ZF2 Album tutorial and set up zfTable module, which is availible here:

https://github.com/dudapiotr/ZfTable

I have followed the install instructions on this site, and I feel that is fine. I do however feel there is a lack of detail on the implementation part for someone new to zendframework 2.

Could anyone explain how to take a basic example and implement the result into the table? I think the Album example is perfect as many people use this as a starting block.

http://dudapiotr.eu/table/base

The only information this site gives in reference to get this working after the basic install instructions is a class.

Some details of where to put this class, how to call it etc would be great.

I think this would be a great use to many others who seem to have this problem (but no solution or tutorial seems to be out there hehe)

class Base extends AbstractTable
{

    protected $config = array(
        'name' => 'Base table',
        'showPagination' => true,
        'showQuickSearch' => false,
        'showItemPerPage' => true,
        'itemCountPerPage' => 20,
        'showColumnFilters' => false,
        'showExportToCSV ' => false,
        'valuesOfItemPerPage' => array(5, 10, 20, 50 , 100 , 200),
        'rowAction' => ''
    );

    //Definition of headers
    protected $headers = array(
        'idcustomer' => array('title' => 'Id', 'width' => '50') ,
        'name' => array('title' => 'Name' ),
        'surname' => array('title' => 'Surname' ),
        'street' => array('title' => 'Street'),
        'city' => array('title' => 'City' ),
        'active' => array('title' => 'Active' , 'width' => 100 ),
    );

    public function init()
    {
    }

    protected function initFilters(\Zend\Db\Sql\Select $query)
    {

    }
}

Thanks,

1

1 Answers

2
votes

I managed to get this working, after much toil and trouble.

What I would say to people trying to do the same:

After you follow the basic instructions, look in the \vendor\dudapiotr\zftable folder.

Here you can see the setup of how he got everything to work. For example the structure,

Controller Example -> Model, TableExample

I used this to implement it into my own module. This ofcourse requires you to change namespaces and module names etc.

If people reply to this thread I will consider making a guide, as it took me over 12 hours to work out so I am sure others will have the same problems.

When it is working, it is great.. keep trying