PHP code example of hustshenl / yii2-metronic

1. Go to this page and download the library: Download hustshenl/yii2-metronic library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hustshenl / yii2-metronic example snippets


  echo Menu::widget([
      'items' => [
          // Important: you need to specify url as 'controller/action',
          // not just as 'controller' even if default action is used.
          [
            'icon' => '',
            'label' => 'Home',
            'url' => ['site/index']
          ],
          // 'Products' menu item will be selected as long as the route is 'product/index'
          ['label' => 'Products', 'url' => ['product/index'], 'items' => [
              ['label' => 'New Arrivals', 'url' => ['product/index', 'tag' => 'new']],
              ['label' => 'Most Popular', 'url' => ['product/index', 'tag' => 'popular']],
          ]],
          ['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest],
      ],
      'search' => [
          // 

  // Classic menu with search box
  echo HorizontalMenu::widget([
      'items' => [
          // Important: you need to specify url as 'controller/action',
          // not just as 'controller' even if default action is used.
          ['label' => 'Home', 'url' => ['site/index']],
          // 'Products' menu item will be selected as long as the route is 'product/index'
          ['label' => 'Products', 'url' => ['product/index'], 'items' => [
              ['label' => 'New Arrivals', 'url' => ['product/index', 'tag' => 'new']],
              ['label' => 'Most Popular', 'url' => ['product/index', 'tag' => 'popular']],
          ]],
          ['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest],
      ],
      'search' => [
          //     'label' => 'Column 1', // First column title
                      'items' => [
                          ['label' => 'Column 1 Item 1'],
                          ['label' => 'Column 1 Item 2'],
                      ]
                  ],
                  [
                      'label' => 'Column 2', // Second column title
                      'items' => [
                          ['label' => 'Column 2 Item 1'],
                          ['label' => 'Column 2 Item 2'],
                      ]
                  ],
              ]
          ],
          ['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest],
      ],
  ]);
  

  echo Nav::widget([
      'items' => [
          [
              'icon' => 'fa fa-warning',
              'badge' => Badge::widget(['label' => 'New', 'round' => false]),
              'label' => 'Home',
              'url' => ['site/index'],
              'linkOptions' => [...],
          ],
          [
              'label' => 'Dropdown',
              'items' => [
                   ['label' => 'Level 1 - Dropdown A', 'url' => '#'],
                   '<li class="divider"></li>',
                   '<li class="dropdown-header">Dropdown Header</li>',
                   ['label' => 'Level 1 - Dropdown B', 'url' => '#'],
              ],
          ],
      ],
  ]);
  

   DateRangePicker::widget([
       'mode' => DateRangePicker::MODE_ADVANCE,
       'labelDateFormat' => 'MMMM D, YYYY',
       'type' => DateRangePicker::TYPE_BLUE,
       'clientOptions' => [
           'format' => 'YYYY-MM-DD',
           'ranges' => new \yii\web\JsExpression("{
               'Today': [moment(), moment()],
               'Yesterday': [moment().subtract('days', 1), moment().subtract('days', 1)],
               'Last 7 Days': [moment().subtract('days', 6), moment()],
               'Last 30 Days': [moment().subtract('days', 29), moment()],
               'This Month': [moment().startOf('month'), moment().endOf('month')],
               'Last Month': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
           }"),
       ],
       'name' => 'date',
       'icon' => 'fa fa-calendar',
       'value' => '2014-02-15 - 2014-02-18',
  ]);
  

  // Simple portlet
  Portlet::begin([
    'icon' => 'fa fa-bell-o',
    'title' => 'Title Portlet',
  ]);
  echo 'Body portlet';
  Portlet::end();
 
  // Portlet with tools, actions, scroller, events and remote content
  Portlet::begin([
    'title' => 'Extended Portlet',
    'scroller' => [
      'height' => 150,
      'footer' => ['label' => 'Show all', 'url' => '#'],
    ],
    'clientOptions' => [
      'loadSuccess' => new \yii\web\JsExpression('function(){ console.log("load success"); }'),
      'remote' => '/?r=site/about',
    ],
    'clientEvents' => [
      'close.mr.portlet' => 'function(e) { console.log("portlet closed"); e.preventDefault(); }'
    ],
    'tools' => [
      Portlet::TOOL_RELOAD,
      Portlet::TOOL_MINIMIZE,
      Portlet::TOOL_CLOSE,
    ],
  ]);
  

  echo Select2::widget([
      'name' => 'select',
      'data' => ['1' => 'Item 1', '2' => 'Item 2'],
      'multiple' => true,
  ]);
  

  echo IonRangeSlider::widget([
      'name' => 'ionRangeSlider',
      'clientOptions' => [
          'min' => 0,
          'max' => 5000,
          'from' => 1000, // default value
          'to' => 4000, // default value
          'type' => 'double',
          'step' => 1,
          'prefix' => "$",
          'prettify' => false,
          'hasGrid' => true
      ],
  ]);
  

  echo Spinner::widget([
      'model' => $model,
      'attribute' => 'country',
      'size' => Spinner::SIZE_SMALL,
      'buttonsLocation' => Spinner::BUTTONS_LOCATION_VERTICAL,
      'clientOptions' => ['step' => 2],
      'clientEvents' => ['changed' => 'function(event, value){ console.log(value);}'],
  ]);
  

  echo Spinner::widget([
      'name'  => 'country',
      'clientOptions' => ['step' => 2],
  ]);
 

  echo Accordion::widget([
      'items' => [
          [
              'header' => 'Item 1',
              'content' => 'Content 1...',
              // open its content by default
              'contentOptions' => ['class' => 'in'],
              'type' => Accordion::ITEM_TYPE_SUCCESS,
          ],
          [
              'header' => 'Item 2',
              'content' => 'Content 2...',
          ],
      ],
      'itemConfig' => ['showIcon' => true],
 ]);
  

  Note::widget([
      'title' => 'Success! Some Header Goes Here',
      'body' => 'Duis mollis, est non commodo luctus',
      'type' => Note::TYPE_INFO,
  ]);
  

  Note::begin(['type' => Note::TYPE_DANGER]);
  echo 'Some title and body';
  Note::end();