2017 © Pedro Peláez
 

yii2-extension yii2-spfjs

yii2 plugin with spfjs for fast navigation and page updates

image

mgilangjanuar/yii2-spfjs

yii2 plugin with spfjs for fast navigation and page updates

  • Friday, February 17, 2017
  • by mgilangjanuar
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

yii2-spfjs

This is an extension for yii2 with spfjs (github.com/youtube/spfjs) for fast navigation and with pace (github.com/HubSpot/pace) for web page progress bar., (*1)

Get Started

Setup AppAsset

Add this in depends attribute in your AppAsset class, (*2)

public $depends = [
    // other depends bundle here
    'mgilangjanuar\yii2spf\SpfAssetBundle',
];

Setup Controller

In all controllers you want, implement method behaviors() and add this, (*3)

public function behaviors()
{
    return [
        // add yii2spf behavior
        'spfjs' => [
            'class' => \mgilangjanuar\yii2spf\ControllerBehavior::className(),

            // default attributes value
            'title' => [
                'contentBetween' => ['<title>', '</title>']
            ],
            'styles' => [
                'contentBetween' => ['<!-- STYLES CONTENT -->', '<!-- END OF STYLES CONTENT -->']
            ],
            'body' => [
                // get from id #main-content content
                'main-content' => ['contentBetween' => ['<!-- MAIN CONTENT -->', '<!-- END OF MAIN CONTENT -->']]

                // you can add others elements in body here
                // ...
            ],
            'scripts' => [
                'contentBetween' => ['<!-- SCRIPTS CONTENT -->', '<!-- END OF SCRIPTS CONTENT -->']
            ],
        ],

        // others behaviors here...
    ];
}

Setup Main Layout

After register AppAsset in your main layout, add this for pace widget, (*4)

\mgilangjanuar\yii2spf\PaceWidget::widget([
    'color'=>'red',
    'theme'=>'minimal',
    'options'=>[
        'ajax'=>['trackMethods'=>['GET','POST','AJAX']]
    ]
]);

Find <?php $this->head() ?> in main layout and add this comments line between that code, (*5)

<!-- STYLES CONTENT -->
<?php $this->head() ?>
<!-- END OF STYLES CONTENT -->

Find <?php $this->endBody() ?> and add this comments line between that, (*6)

<!-- SCRIPTS CONTENT -->
<?php $this->endBody() ?>
<!-- END OF SCRIPTS CONTENT -->

And finnaly, add this comments line between your dynamic content and add div tag with id main-content (or as you defined in behavior method in your class)., (*7)

<div id="main-content" class="container">
<!-- MAIN CONTENT -->
<?= Breadcrumbs::widget([
    'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
<?= $content ?>
<!-- END OF MAIN CONTENT -->
</div>

License

yii2-spfjs is released under the MIT License. See the bundled LICENSE.md for details., (*8)

The Versions

17/02 2017

dev-master

9999999-dev

yii2 plugin with spfjs for fast navigation and page updates

  Sources   Download

MIT

The Requires

 

17/02 2017

0.1.8

0.1.8.0

yii2 plugin with spfjs for fast navigation and page updates

  Sources   Download

MIT

The Requires

 

17/02 2017

0.1.7

0.1.7.0

yii2 plugin with spfjs for fast navigation and page updates

  Sources   Download

MIT

The Requires

 

17/02 2017

0.1.6

0.1.6.0

yii2 plugin with spfjs for fast navigation and page updates

  Sources   Download

MIT

The Requires

 

17/02 2017

0.1.5

0.1.5.0

yii2 plugin with spfjs for fast navigation and page updates

  Sources   Download

MIT

The Requires

 

17/02 2017

0.1.4

0.1.4.0

yii2 plugin with spfjs for fast navigation and page updates

  Sources   Download

MIT

The Requires

 

17/02 2017

0.1.3

0.1.3.0

yii2 plugin with spfjs for fast navigation and page updates

  Sources   Download

MIT

The Requires

 

17/02 2017

0.1.1

0.1.1.0

yii2 plugin with spfjs for fast navigation and page updates

  Sources   Download

MIT

The Requires