在Bootstrap中更改布局 [英] Change Layout in Bootstrap

查看:101
本文介绍了在Bootstrap中更改布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是zend的新手,在引导程序中更改布局时遇到问题.我想在用户登录后更改布局.

I am new with zend and I have a problem changing my layout in the bootstrap. I want to change my layout when the user is logged in.

我更改引导程序布局的功能如下:

My function to change the layout in the bootstrap is like this:

protected function _initAuthState()
{
$layout = new Zend_Layout;
$layout->setLayoutPath('/layouts/scripts');

if (Zend_Auth::getInstance()->hasIdentity()):
// Logged in.
$layout->setLayout(layout2);

else:
// Not Logged in.
$layout->setLayout(‘layout’);
endif;
}

此代码不起作用,布局始终相同...帮助!

This code doesn't work, the layout is always the same ... help!

推荐答案

您正在修改 new 布局实例,而不是系统正在使用的实例.

You are modifying a new layout instance, not the instance that is being used by the system.

我假设您正在application.ini中指定布局参数.因此,您需要:

I assume you are specifying your layout params in application.ini. So you need:

$this->bootstrap('layout');
$layout = $this->getResource('layout');

然后在此布局实例上执行检查/修改.

Then perform your check/modification on this layout instance.

顺便说一句,更改布局通常是使用前控制器插件完成的.仍然可以尽早运行以完成任务,但通常更具可配置性和可重用性.请参见此处这里有两个例子.

BTW, changing layout is often done using a front-controller plugin. Still runs early enough to do the job, but is often more configurable and re-usable. See here and here for two examples.

这篇关于在Bootstrap中更改布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆