定制 jasonroyle/li3_element 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jasonroyle/li3_element

最新稳定版本:0.2.1

Composer 安装命令:

composer require jasonroyle/li3_element

包简介

Element helper for Lithium

README 文档

README

Installation

Composer

composer require jasonroyle/li3_element

Git

git submodule add https://github.com/jasonroyle/li3_element.git libraries/li3_element

Enable the Library

Make the application aware of the library by adding the following to app/config/bootstrap/libraries.php.

Libraries::add('li3_element');

Render

Renders an element.

Params

  • $element (string)
  • $data (array, optional)

Return

Rendered HTML (string)

Grid

Iterates through items and renders an element per item. The elements are wrapped in row and column divs and returned as a rendered HTML string.

Params

  • $element (string)
  • $data (array)
  • $options (array, optional)

Return

Rendered HTML (string)

Examples

By default the first value of the data array will be used as the items of which to iterate through.

The following example iterates through posts, replaces the post value of the data array with the individual post and passes the data on to the element to render.

echo $this->element->grid('post', ['post' => $posts]);

To pass more data to each of the elements simply append the data array.

echo $this->element->grid('post', [
	'post' => $posts,
	'foo' => $foo,
	'bar' => $bar
]);

Set columns, offset and max options to control how the items are displayed.

The following example renders 3 posts per row, ignores the first 2 posts and limits the amount of displayed posts to 9.

echo $this->element->grid('post', ['post' => $posts], [
	'columns' => 3,
	'offset' => 2,
	'max' => 9
]);

Appling attributes to rows and columns.

The following example applies the class="row" attribute to each row and the class="column" attribute to each column.

echo $this->element->grid('post', ['post' => $posts], [
	'columns' => 5,
	'row' => ['class' => 'row'],
	'column' => ['class' => 'column']
]);

The following example renders the same as the last except the attribute class="column first" is applied to every first column of each row and the attribute class="column last" is applied to every last column of each row.

echo $this->element->grid('post', ['post' => $posts], [
	'columns' => 5,
	'row' => ['class' => 'row'],
	'column' => ['class' => 'column'],
	'first_column' => ['class' => 'column first'],
	'last_column' => ['class' => 'column last']
]);

The following example renders the same as the last except the last row contains only one column. The attribute class="column first last" is applied to this column.

echo $this->element->grid('post', ['post' => $posts], [
	'columns' => 5,
	'max' => 11,
	'row' => ['class' => 'row'],
	'column' => ['class' => 'column'],
	'first_column' => ['class' => 'column first'],
	'last_column' => ['class' => 'column last'],
	'first_and_last_column' => ['class' => 'column first last']
]);

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固