delboy1978uk/bone-view
最新稳定版本:v1.10.3
Composer 安装命令:
composer require delboy1978uk/bone-view
包简介
View package for Bone Framework
README 文档
README
View package for Bone Framework
installation
Bone View is a core dependency of Bone Framework, you install Bone via the skeleton project delboy1978uk/bonemvc
usage
bone-view uses league/plates as its view engine, see the docs for that. To get an instance of the view engine from
the dependency injection container, call $container->get(ViewEngine::class). You can also simply extend Bone\Controller\Controller
and pass through Init::controller($controller) to get a ViewEngine injected in your class instance.
layouts
Your app by default has layouts in src/App/View/layouts. You can switch layouts in your controller by adding a
layout header to your response like so:
return $response->withHeader('layout', 'layouts::your-template');
view extensions
alert box
From a view file, you can call
$this->alertBox($messages);
where messages is an array of variable length, but the last
is the bootstrap alert-* class, so a value like info, danger, warning, success, etc.
view helpers
alert box
The view extension just calls this class Bone\View\Helper\AlertBox, but you can instantiate it and call it yourself.
$alert = new \Bone\View\Helper\AlertBox(); echo $alert->alertBox(['Great success!', 'success']);
Paginator
This should be moved into its own package (imho), however this will render bootstrap compatible paginator nav HTML.
<?php $viewHelper = new \Bone\View\Helper\Paginator(); $viewHelper->setCurrentPage(3); // this number will come from the url $viewHelper->setUrl('/some/page/:number'); // this is the url you are generating $viewHelper->setUrlPart(':number'); // this is the part of the url you will replace with the page number $viewHelper->setPageCount(10); // this is the total number of pages $viewHelper->setPageCountByTotalRecords(50, 10); // Or pass in a row count and num per page to set page count $viewHelper->setPagerSize(5); // this is the number of pages directly clickable in the generated pager $pagination = $viewHelper->render();
统计信息
- 总下载量: 4.09k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-01