我在使用模板显示视图时遇到问题。我的模板如下所示:
<?php
$this->load->view('includes/header');
if($this->session->userdata('is_loggedin')!=1) //check if logged in
{
$this->load->view('includes/not_loggedin'); //includes this when not logged in
}
else //includes all this when is logged in
{
if(isset($content)) //check if content variable isnt empty
{
$this->load->view($content); //THIS IS MY CONTENT WHIC IS DISPLAYED IN WRONG POS
}
$this->load->view('includes/is_loggedin'); //
}
$this->load->view('includes/footer');
?>
错误的位置是指我的表单显示在 HTML 结构之外的左上角。这是检查元素窗口的副本。注意 div 的位置;头部标签为空;并且,头部信息在正文中。
<html lang="en">
<head></head> //head tags are empty
<body>
<div id="settings">...</div> //this is my loaded div
<meta charset="utf-8">
<title>Sludinājumu lapa</title> //head info outside tags
<link href="/assets/css/style.css" type="text/css" rel="stylesheet">
<div id="wrapper">....</div> //i need settings div inside wrapper div
</body>
</html>
如果不加载该视图,HTML 结构就可以了。将 is_loggedin 和 not_logged 加载到视图中也没有问题。
我的标题包含:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sludinājumu lapa</title>
<link rel="stylesheet" type="text/css" href="/assets/css/style.css">
</head>
<body>
<div id="wrapper">
页脚包含:
<foter>
<p>developed by kriss</p>
</foter>
</div> //End of "wrapper" div
</body>
</html>
从控制器我传递这样的数据:
$data['content'] = $this->load->view('vchangeinfo');
$this->load->view('template', $data);
任何想法为什么一切都如此混乱?