本文整理汇总了PHP中yii\web\Controller::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::render方法的具体用法?PHP Controller::render怎么用?PHP Controller::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\Controller
的用法示例。
在下文中一共展示了Controller::render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* If we are acting in the module context and the layout is empty we only should renderPartial the content.
*
* @param string $view The name of the view file (e.g. index)
* @param array $params The params to assign into the value for key is the variable and value the content.
*
* @return string
*/
public function render($view, $params = [])
{
if (!empty($this->module->context) && empty($this->layout)) {
return $this->renderPartial($view, $params);
}
return parent::render($view, $params);
}
示例2: display
/**
* Modified render method to display the view. This takes in the view id as a parameter instead of
* view name.
*
* @param int $view the view identifier as set in one of Module::VIEW constants
* @param array $params the parameters (name-value pairs) that should be made available in the view.
* These parameters will not be available in the layout.
*
* @return string the rendering result
*/
public function display($view, $params = [])
{
if (!empty($this->_module->getLayout($view))) {
$this->layout = $this->_module->getLayout($view);
}
$view = $this->fetchView($view);
return parent::render($view, $params);
}
示例3: render
public function render($view, $params = [])
{
if (Yii::$app->request->isAjax) {
return $this->renderAjax($view, $params);
} else {
return parent::render($view, $params);
}
}
示例4: render
public function render($view, $data = NULL, $return = false)
{
if (isset($_POST['minimal'])) {
echo \yii\helpers\Json::encode(parent::renderPartial($view, $data, true));
} else {
return parent::render($view, $data, $return);
}
}
示例5: render
/**
* Автоматический renderPartial, если ajax-запрос.
*/
public function render($view, $params = [], $returnContent = false)
{
if (Yii::$app->request->isAjax) {
return parent::renderPartial($view, $params, $returnContent);
} else {
return parent::render($view, $params, $returnContent);
}
}
示例6: render
public function render($params = [], $view = '')
{
if ($view == '') {
$view = \Yii::$app->controller->action->id;
}
$view = $view . ".html";
$arr = array_merge($params, $this->assign);
return parent::render($view, $arr);
}
示例7: render
public function render($view, $params = [])
{
$position = $this->module->positionMenu;
if (in_array($position, ['left', 'top', 'right'])) {
return parent::render("/layouts/{$position}-menu", ['view' => $view, 'params' => $params]);
} else {
return parent::render($view, $params);
}
}
示例8: render
public function render($view = null, $params = [])
{
if (is_array($view)) {
$params = $view;
$view = null;
}
if ($view === null) {
$view = $this->action->id;
}
return parent::render($view, $params);
}
示例9: render
public function render($view, $params = [])
{
$ua_arr = ['ua' => (object) $this->getua()];
$urlParams = ['urlParams' => (object) Yii::$app->request->getQueryParams()];
$tpldata = array_merge($params, $urlParams, $ua_arr);
$tpldata['APP_CODE'] = @\Yii::$app->params['app_code'];
Yii::$app->view->params['tpldata'] = (object) $tpldata;
$params['tplData'] = $tpldata;
Yii::$app->response->formatters[Response::FORMAT_HTML] = 'mysoft\\web\\MyHtmlResponseFormatter';
return parent::render($view, $params);
}
示例10: render
public function render($view, $params = [])
{
$devicedetect = \Yii::$app->devicedetect;
$isMobile = $devicedetect->isMobile();
$isTablet = $devicedetect->isTablet();
$mobileTpl = $isMobile && !$isTablet;
// detect and change layout
if ($mobileTpl) {
$this->layout = '@app/views/layouts/sp_main';
}
// detect and render view
$detectView = $view . ($mobileTpl ? '_sp' : '');
$detectPath = parent::getViewPath() . "/{$detectView}.php";
return parent::render(file_exists($detectPath) ? $detectView : $view, $params);
}
示例11: render
/**
* @param string $view
* @param array $params
* @return string
*/
public function render($view, $params = [])
{
if (!$this->beforeRender || $this->module instanceof Application) {
return parent::render($view, $params);
}
try {
$viewApp = $this->beforeRender . $this->module->id . '/' . $this->id . '/' . $view;
return parent::render($viewApp, $params);
} catch (InvalidParamException $e) {
\Yii::error($e->getMessage());
try {
return parent::render($view, $params);
} catch (InvalidParamException $e) {
return $this->output($e->getMessage());
}
}
}
示例12: render
/**
* @param string $view
* @param array $params
* @return string
*/
public function render($view, $params = [])
{
if ($this->module instanceof Application) {
return parent::render($view, $params);
}
if (strpos($view, '/') && !strpos($view, '@app/views')) {
return parent::render($view, $params);
}
$viewDir = "@app/views/modules/" . $this->module->id . '/' . $this->id;
$viewApp = $viewDir . '/' . $view;
if (isset(\Yii::$app->view->theme->pathMap['@app/views'])) {
$tmpPaths = [];
foreach (\Yii::$app->view->theme->pathMap['@app/views'] as $path) {
$tmpPaths[] = $path . "/modules/" . $this->module->id . '/' . $this->id;
}
$tmpPaths[] = $this->viewPath;
\Yii::$app->view->theme->pathMap = ArrayHelper::merge(\Yii::$app->view->theme->pathMap, [$viewDir => $tmpPaths]);
}
return parent::render($viewApp, $params);
}
示例13: render
public function render($view, $params = [])
{
$this->beforeRender($params);
return parent::render($view, $params);
}
示例14: render
public function render($view, $params = [])
{
\worstinme\forum\assets\Asset::register($this->view);
return parent::render($view, $params);
}
示例15: render
/**
* redefine controller render function
*
* @see \yii\base\Controller::render()
*/
public function render($view, $params = [])
{
$content = parent::render($view, $params);
return $this->compressHtml($content);
}