mattdanger / phalcon-table-sort

Phalcon HTML 表格排序组件

dev-master 2016-03-03 00:49 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:42:14 UTC


README

Phalcon HTML 表格排序组件

要求

  • Phalcon v1.4.x

安装

使用 Composer 安装

{
	"require": {
		"mattdanger/phalcon-table-sort": "dev-master"
	}
}

还需要将每个函数添加到 Volt 服务中

$di->set('view', function () use ($config) {

  $view = new View();
  // ...
  $view->registerEngines(array(
    '.volt' => function ($view, $di) use ($config) {

      $volt = new VoltEngine($view, $di);

      $volt->getCompiler()->addFunction('sortLink', function ($resolvedArgs, $expArgs) {
        return 'TableSort\Sort::sortLink(' . $resolvedArgs . ')';
      });
      $volt->getCompiler()->addFunction('sortIcon', function ($resolvedArgs, $expArgs) {
        return 'TableSort\Sort::sortIcon(' . $resolvedArgs . ')';
      });
      // ... 

      return $volt;
    },
    // ...
  ));

  return $view;

});

使用辅助工具

以下是包含的内容列表

sortLink($key, $default_sort = 'ASC')

返回带有排序顺序的格式化 URI 字符串

sortIcon($key, $default = FALSE)

返回排序图标