定制 mgilangjanuar/yii2-spfjs 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mgilangjanuar/yii2-spfjs

Composer 安装命令:

composer require mgilangjanuar/yii2-spfjs

包简介

yii2 plugin with spfjs for fast navigation and page updates

README 文档

README

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.

Get Started

Setup AppAsset

Add this in depends attribute in your AppAsset class

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

Setup Controller

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

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

\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

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

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

<!-- 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).

<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.

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固