jmleroux/jmlzf-helpers

This package is abandoned and no longer maintained. No replacement package was suggested.

A collection of ZF2 helpers

0.1 2013-10-26 13:08 UTC

This package is not auto-updated.

Last update: 2020-01-20 03:25:00 UTC


README

A collection of helpers for Zend Framework 2

Latest Stable Version Build Status Coverage Status

CurrentRoute

This helper gives access to the matched route in the view. Useful for adding query params for example.

Usage
<?php echo $this->currentRoute(); ?>

QueryParams

This helper provides access to the query parameters as an associative array.

Usage
<?php $queryParams = $this->queryParams(); ?>

<?php // do something with $queryParams ?>

Sortable

This helper add or replace query parameters for sorting purpose.

Usage
<table>
  <thead>
    <th>
      <a href="<?php echo $this->sortable('id'); ?>">ID</a>
    </th>
    <th>
      <a href="<?php echo $this->sortable('label'); ?>">Label</a>
    </th>
  </thead>
  <tbody>
  // table cells
  </tbody>
</table>

<?php // here goes the pagination control (with a paginate helper to come) ?>

Ouput :

<table>
  <thead>
    <th>
      <a href="http://example.com/?sort=id&direction=asc">ID</a>
    </th>
    <th>
      <a href="http://example.com/?sort=label&direction=asc">Label</a>
    </th>
  </thead>
  <tbody>
  // table cells
  </tbody>
</table>

If you click on the ID column, the next output will be

<table>
  <thead>
    <th>
      <a href="http://example.com/?sort=id&direction=desc">ID</a>
    </th>
    <th>
      <a href="http://example.com/?sort=label&direction=asc">Label</a>
    </th>
  </thead>
  <tbody>
  // table cells
  </tbody>
</table>

Maybe i'll wrap this one in another helper to be able to generate a class for the th element.