Class dmitrybtn\yimp\Yimp
Inheritance | dmitrybtn\yimp\Yimp » yii\base\BaseObject |
---|
Main package class, used to render layout snippets.
To use YIMP you must create an object of this class and call dmitrybtn\yimp\Yimp::register() in layout. Also you should extend dmitrybtn\yimp\Navigator class
in your application and add it to your controllers as nav
property. Then, in controller actions you should set
necessary properties of Navigator and they will be automatically shown in layout.
When this class inits, it looks for nav
property of current controller. If this property absents or is not instance
of dmitrybtn\yimp\Navigator, it will be created via DI-container using 'yimp-nav' alias. So, if you want to use YIMP with third-party modules,
you should use 'yimp-nav' alias to set your default navigator in DI-container:
Yii::$container->set('yimp-nav', [
'class' => '\your\navigator\Class',
// Your config
])
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$menu | dmitrybtn\yimp\MenuAdapter | Component, used to render menu widgets | dmitrybtn\yimp\Yimp |
$nav | dmitrybtn\yimp\Navigator | Component, used to get layout config from controller | dmitrybtn\yimp\Yimp |
$templates | array | HTML templates for layout snippets. | dmitrybtn\yimp\Yimp |
$view | \yii\web\View | View object, used to render layout widgets. | dmitrybtn\yimp\Yimp |
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Overrides parent method to use items from dmitrybtn\yimp\Yimp::$templates as functions. | dmitrybtn\yimp\Yimp |
headerDesktop() | Renders <h1> tag for desktops |
dmitrybtn\yimp\Yimp |
headerMobile() | Renders page header, displayed in navbar on mobiles | dmitrybtn\yimp\Yimp |
init() | Class initialisation | dmitrybtn\yimp\Yimp |
menuLeft() | Renders left menu | dmitrybtn\yimp\Yimp |
menuRight() | Renders right menu | dmitrybtn\yimp\Yimp |
menuTop() | Renders top menu | dmitrybtn\yimp\Yimp |
navbar() | Renders navbar | dmitrybtn\yimp\Yimp |
register() | Registers asset bundles for YIMP | dmitrybtn\yimp\Yimp |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
DEFAULT_MENU_ALIAS | 'yimp-menu' | DI alias, used to instantiate dmitrybtn\yimp\Yimp::$menu property | dmitrybtn\yimp\Yimp |
DEFAULT_MENU_CONFIG | array('class' => 'dmitrybtn\yimp\MenuAdapter') | DI config, used to instantiate dmitrybtn\yimp\Yimp::$menu property | dmitrybtn\yimp\Yimp |
DEFAULT_NAV_ALIAS | 'yimp-nav' | DI alias, used to instantiate dmitrybtn\yimp\Yimp::$nav property | dmitrybtn\yimp\Yimp |
DEFAULT_NAV_CONFIG | array('class' => 'dmitrybtn\yimp\Navigator') | DI config, used to instantiate dmitrybtn\yimp\Yimp::$nav property | dmitrybtn\yimp\Yimp |
DESKTOP | 'desktop' | Used by dmitrybtn\yimp\MenuAdapter in dmitrybtn\yimp\MenuAdapter::$mode property and visibleMode menu item config to config visible
property separately for desktops and mobiles.
|
dmitrybtn\yimp\Yimp |
FOOTER | 'blockFooter' | Footer marker, used to define blocks in layout | dmitrybtn\yimp\Yimp |
MOBILE | 'mobile' | Used by dmitrybtn\yimp\MenuAdapter in dmitrybtn\yimp\MenuAdapter::$mode property and visibleMode menu item config to config visible
property separately for desktops and mobiles.
|
dmitrybtn\yimp\Yimp |
SIDEBAR_LEFT | 'blockLeftSidebar' | Left sidebar marker, used to define blocks in layout | dmitrybtn\yimp\Yimp |
SIDEBAR_RIGHT | 'blockRightSidebar' | Right sidebar marker, used to define blocks in layout | dmitrybtn\yimp\Yimp |
Property Details
Component, used to render menu widgets
Component, used to get layout config from controller
HTML templates for layout snippets.
Each item can be used by calling method with same name, i.e. $yimp->beginSidebars()
.
View object, used to render layout widgets.
Method Details
Overrides parent method to use items from dmitrybtn\yimp\Yimp::$templates as functions.
public mixed|string __call ( $name, $arguments ) | ||
$name | string | |
$arguments | array |
Renders <h1>
tag for desktops
public string headerDesktop ( ) |
Renders page header, displayed in navbar on mobiles
public string headerMobile ( $options = [] ) | ||
$options | array |
Class initialisation
public void init ( ) | ||
throws | \yii\base\ErrorException | |
---|---|---|
throws | \yii\base\InvalidConfigException |
Renders left menu
public string menuLeft ( $config = [] ) | ||
$config | array | |
return | string | Left menu HTML |
---|---|---|
throws | Exception |
Renders right menu
public string menuRight ( $config = [] ) | ||
$config | array | |
return | string | Right menu HTML |
---|---|---|
throws | Exception |
Renders top menu
public string menuTop ( $config = [] ) | ||
$config | array | |
return | string | Top menu HTML |
---|---|---|
throws | Exception |
Renders navbar
public string navbar ( ) | ||
return | string | Navbar HTML |
---|
Registers asset bundles for YIMP
public void register ( \yii\web\View $view ) | ||
$view | \yii\web\View |