derek / li3_hui
Lithium ui 插件
dev-master
2013-12-24 10:47 UTC
Requires
- php: >=5.3
- composer/installers: *
- joseym/li3_installer: master
Suggests
- UnionOfRAD/lithium: Lithium is required for this plugin.
This package is not auto-updated.
Last update: 2024-09-23 15:30:50 UTC
README
安装
将代码检出至您的库目录
cd libraries
git clone git@github.com:/johnny13/li3_hui.git
将库包含在您的/app/config/bootstrap/libraries.php中
Libraries::add('li3_hui');
define('HUI_PATH', dirname(LITHIUM_APP_PATH) . '/libraries/li3_hui' );
li3_hui(《li3_hui》)插件提供了一种简单的接口来向用户显示状态消息,一些HTML构建器,以及其他东西。
集成
<?php
// config/bootstrap/libraries.php:
Libraries::add('li3_hui');
define('HUI_PATH', dirname(LITHIUM_APP_PATH) . '/libraries/li3_hui' );
?>
自定义视图
一旦您安装并包含了这个库,您可能想使用它。从库中调用自定义布局可能很棘手。这基本上需要您为每个控制器进行设置。需要有一个init()方法来定义库的路径。
您的控制器应具有此函数
<?php
public function _init() {
parent::_init();
$this->controller = $this->request->controller;
$this->library = $this->request->library;
$this->_render['paths'] = array(
'template' => array(
LITHIUM_APP_PATH . '/views/{:controller}/{:template}.{:type}.php',
HUI_PATH . '/views/{:controller}/{:template}.{:type}.php',
'{:library}/views/{:controller}/{:template}.{:type}.php',
),
'layout' => array(
LITHIUM_APP_PATH . '/views/layouts/{:layout}.{:type}.php',
HUI_PATH . '/views/layouts/{:layout}.{:type}.php',
'{:library}/views/layouts/{:layout}.{:type}.php',
),
'element' => array(
LITHIUM_APP_PATH . '/views/elements/{:template}.{:type}.php',
HUI_PATH . '/views/elements/{:template}.{:type}.php',
'{:library}/views/elements/{:template}.{:type}.php',
),
);
}
?>
然后在同一控制器中稍后渲染视图,如下所示
<?php
public function index() {
$title = "whatevah";
$this->set(array('title' => $title));
return $this->render(array('layout' => 'hui', 'library' => 'li3_hui'));
}
?>