【问题标题】:create master page layout in codeigniter master-page layout在 codeigniter 母版页布局中创建母版页布局
【发布时间】:2018-05-31 17:47:01
【问题描述】:

我正在尝试在调节器中创建母版页布局。但问题是。我收到页面加载错误。

我有 Header.php ,footer.php ,sidebar.php

dashboar_view.php页面是这个

<?php include_once('common/header.php');?>
<div class="content-wrapper">
    <div class="container-fluid">
      <!-- Breadcrumbs-->
      <ol class="breadcrumb">
        <li class="breadcrumb-item">
          <a href="#">Dashboard</a>
        </li>
        <li class="breadcrumb-item active">My Dashboard</li>
      </ol>

      </div>
<!-- HERE WILL BE ALL PAGE DATA WILL BE SHOWN -->
  <?php $this->load->view($content); ?>
    </div>
    <!-- /.container-fluid-->
    <!-- /.content-wrapper-->
<?php require_once('common/footer.php');?>

这是我的控制器功能Dashboard.php

    public function viewchart()
    {
        $data = array('content'=>'viewchart');
        $this->load->view('admin/dashborad_view',$data);
    }

遇到错误

无法加载请求的文件:viewchart.php。

关于为页面内容加载创建动态主布局的帮助。 谢谢

【问题讨论】:

    标签: php codeigniter


    【解决方案1】:

    希望对您有所帮助:

    如果charts_view.php 是您希望在仪表板中显示的视图文件夹中的文件

    你的控制器应该是这样的:

    public function viewchart()
    {
        $chart_content = $this->load->view('charts_view',TRUE);
        $data = array('chart_content'=> $chart_content);
        $this->load->view('admin/dashborad_view',$data);
    }
    

    你的视图应该是这样的:

    <?php include_once('common/header.php');?>
    <div class="content-wrapper">
        <div class="container-fluid">
          <!-- Breadcrumbs-->
          <ol class="breadcrumb">
            <li class="breadcrumb-item">
              <a href="#">Dashboard</a>
            </li>
            <li class="breadcrumb-item active">My Dashboard</li>
          </ol>
    
          </div>
    <!-- HERE WILL BE ALL PAGE DATA WILL BE SHOWN -->
      <?php echo $chart_content; ?>
        </div>
    
    <?php require_once('common/footer.php');?>
    

    更多:https://www.codeigniter.com/user_guide/general/views.html#returning-views-as-data

    【讨论】:

    • pradeep@I 需要在点击链接后动态显示所有视图页面内容
    • pradeep@我正在尝试创建母版页布局概念
    • 无法加载请求的文件:charts_view.php@same 错误
    • charts_view.php 是视图
    • 确保charts_view.php的文件路径正确意味着它在视图文件夹中
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-27
    • 1970-01-01
    相关资源
    最近更新 更多