jmleroux/jmlzf-helpers

此包已被弃用,不再维护。未建议替代包。

一组ZF2助手

0.1 2013-10-26 13:08 UTC

This package is not auto-updated.

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


README

一组Zend Framework 2的助手

Latest Stable Version Build Status Coverage Status

当前路由

此助手可以访问视图中的匹配路由。例如,用于添加查询参数很有用。

使用方法
<?php echo $this->currentRoute(); ?>

查询参数

此助手提供以关联数组形式访问查询参数的能力。

使用方法
<?php $queryParams = $this->queryParams(); ?>

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

可排序

此助手用于添加或替换用于排序的查询参数。

使用方法
<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) ?>

输出

<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>

如果您点击ID列,下一个输出将是

<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>

也许我会用另一个助手包装这个,以便为th元素生成一个类。