By default, Vegas\Mvc\ModuleAbstract
is using Vegas\Mvc\View
with volt extenstion. If
you want to use custom View class, you need to overwrite registerViewComponent method in your
Module.php:
namespace Foo;
class Module extends \Vegas\Mvc\ModuleAbstract
{
public function __construct() {
$this->namespace = __NAMESPACE__;
$this->dir = __DIR__;
}
protected function registerViewComponent($di)
{
$di->set('view', function() use ($di) {
$viewDir = $this->dir . '/views';
$view = new CustomView($di->get('config')->application->view->toArray(), $viewDir);
if (file_exists($viewDir)) {
$view->setViewsDir($viewDir);
}
$view->setEventsManager($di->getShared('eventsManager'));
return $view;
});
}
}
Vegas\Mvc\View
extends Phalcon\Mvc\View
with additional filters and helpers. In
addition you can use absolute path for layouts dir instead relative one.
Cast variable to string.
Usage
{{ variable|toString }}
A simple tag for pagination rendering.
Tag interface
public function pagination($page, $options=array()) {
$defaultSettings = [
'start_end_offset' => 2,
'middle_offset' => 3
];
$settings = array_merge($defaultSettings, $settings);
}
Usage
Make a paginator instance in your controller action...
$paginator = new \Vegas\Paginator\Adapter\ExampleAdapter(...);
$this->view->page = $paginator->getPaginate();
... and use in volt template:
{{ pagination(page[, options]) }}
Options
Preview
Cut text to string of given length and remove all html tags.
Tag interface
public function shortenText($text, $length = 100, $endString = '...')
{
//...
}
Usage
{{ shortenText(text[, length[, endString]]) }}
partialsDir is set | partialsDir is not set | |
includes global partial app/layouts/partials/header/menu.volt2
|
{{ partial('header/menu') }}
or
{{ partial('../../../layouts/partials/header/menu') }}
|
{{ partial('../../../layouts/partials/header/menu') }}
|
include controller view partial
app/modules/Test/views/frontend/test/partials/foo.volt
|
{{ partial('./frontend/test/partials/foo') }}
|
{{ partial('./frontend/test/partials/foo') }}
or
{{ partial('partials/foo') }}
|
include partial from absolute path
app/layouts/partials/header/menu.volt
|
{{ partial(constant("APP_ROOT") ~ "/app/layouts/partials/header/menu") }}
|
{{ partial(constant("APP_ROOT") ~ "/app/layouts/partials/header/menu") }}
|