定制 felixmaier1989/yii2-renderdual 二次开发

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

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

felixmaier1989/yii2-renderdual

最新稳定版本:1.0

Composer 安装命令:

composer require felixmaier1989/yii2-renderdual

包简介

Make your actions compatible for Ajax requests

README 文档

README

Make your actions compatible for Ajax requests

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist felixmaier1989/yii2-renderdual "*"

or add

"felixmaier1989/yii2-renderdual": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by extending your controller:

...
use yii2renderdual\RenderDual;

class SiteController extends Controller
{
    public function behaviors()
    {
        return [
            ...
            \yii2renderdual\RenderDual::className()
        ];
    }

    public function actionAbout()
    {
        Yii::$app->session->setFlash('success', 'Welcome on my home page');
        $fruits = ['banana', 'apple', 'jackfruit', 'papaya'];
        return $this->renderDual('about', compact('fruits'), true);
    }
...

An Ajax call to your site/about action would then return

Array
(
    [flashes] => Array
        (
            [success] => Welcome on my home page
        )
    [params] => Array
        (
            [fruits] => Array
                (
                    [0] => banana
                    [1] => apple
                    [2] => jackfruit
                    [3] => papaya
                )

        )
    [rendered] => <h1>About</h1><p>I like banana, apple, jackfruit, papaya</p>
)

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-26