[英]A PHP Error was encountered Severity: Notice Message: Undefined property: CI_Loader::$p Filename: Templates/public.php Line Number: 24
I have gone through this forum and tried all the options provided but nothing is working for me. 我浏览了这个论坛,尝试了所有提供的选项,但是没有任何工作对我有用。
I developed a CMS using some Codeigniter tutorial. 我使用一些Codeigniter教程开发了CMS。 On my PC everything works well.
在我的PC上,一切正常。 But on the remote server, it has failed to work.
但是在远程服务器上,它无法正常工作。 Below is the code.
下面是代码。 Thanks in advance.
提前致谢。
Here is the view 这是视图
Currently editing: 当前正在编辑:
Currently editing: 当前正在编辑:
<div class="container"> <!-- Static navbar --> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#"><?php echo $this->brand; ?></a> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav navbar-right"> <li><a href="<?php echo base_url(); ?>">Home</a></li> <li><a href="<?php echo base_url(); ?>pages/contact">Contact</a></li> <?php //$CI =& get_instance(); ?> <?php if ($this->p) : ?> //liine 24 <?php foreach($this->p as $page) : ?> <li><a href="<?php echo base_url(); ?>pages/show/<?php echo $page->slug; ?>"><?php echo $page->title; ?></a></li> <?php endforeach; ?> <?php else : ?> <?php endif; ?> </ul> </div><!--/.nav-collapse --> </div><!--/.container-fluid --> </nav> <!-- Main component for a primary marketing message or call to action --> <!-- <div class="well"> --> <?php $this->load->view('Templates/slider'); ?> <!-- </div> --> <div style="margin-top:-55px; min-height: 300px;"> <div class="col-md-12"> <?php $this->load->view($main); ?> </div> </div> <div class="well"> <?php $this->load->view('Templates/foot'); ?> </div> </div> <!-- /container -->
Controller 控制者
class Pages extends Public_Controller { function __construct(){ parent::__construct(); //$this->load->library('p'); } public function index() { $data['featured_pages'] = $this->Page_model->get_featured(); $this->template->load('public', 'default', 'pages/index', $data); } public function show($slug){ $data['p'] = $this->Page_model->get_by_slug($slug); $this->template->load('public', 'default', 'pages/show', $data); } public function contact(){ // $this->template->load('public', 'default', 'pages/contact') die('contact'); }
} }
The error message comes from that $this->p
is not defined. 错误消息来自未定义
$this->p
。 First, it seem that you define $p
not $this->p
in the controller ( show()
-method): 首先,似乎您在控制器中定义了
$p
而不是$this->p
( show()
-method):
$data['p'] = $this->Page_model->get_by_slug($slug);
So the most probable solution would be to change row 24 and 25 to: 因此,最可能的解决方案是将第24和25行更改为:
<?php if (isset($p) && $p) : ?> //liine 24
<?php foreach($p as $page) : ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.