drsqpko5286 2010-12-01 14:58 采纳率: 0%
浏览 60
已采纳

codeigniter:将数据传递给视图中包含的视图

I have a controller and including two views from one function as below

$this->load->view('includes/header',$data);
$this->load->view('view_destinations',$data);

The view file view_destinations.php including a php menu file as follows

<? $this->load->view('includes/top_menu'); ?>

My question is, how can I pass data that is fetched from the controller to this included top_menu.php ?

Thank you guys

  • 写回答

5条回答 默认 最新

  • donglaoe2979 2010-12-01 15:04
    关注

    Inside your controller, have

    $data['nestedView']['otherData'] = 'testing';
    

    before your view includes.

    When you call

    $this->load->view('view_destinations',$data);
    

    the view_destinations file is going to have

    $nestedView['otherData'];
    

    Which you can at that point, pass into the nested view file.

    <? $this->load->view('includes/top_menu', $nestedView); ?>
    

    And inside your top_menu file you should have $otherData containing 'testing'.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥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键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算