doucai6663 2014-11-18 07:52
浏览 9

将变量从布局渲染到另一个布局

In layout I am getting some value:

$quote = Quotes::model()->findAll(array('order'=>'id DESC', 'limit'=>1));

And it works Ok, no matter it is a bad practice to call model from view. In another layout in the same folder I cant do the same. If it matters, this layouts shows on the same page. I am responding straight to the Model and the Controller doesnt render any variables to view. Is there a way to send this var to custom layout or view?

  • 写回答

3条回答 默认 最新

  • dqg2269 2014-11-18 09:52
    关注

    You can create a method inside your controller that will return the value you need, and then you can call this method from view. Or if you are using $this->render() inside your view, then you just have to pass this variable forward to your custom view: $this->render('quotes',$quotes);

    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法