I've been developing a custom CMS using Codeigniter locally and I've just gotten to the point where I need to upload it to a staging server to do some more testing.
Everything works except for the sidebar section of the site that uses a widget system. I initially thought it was just differences between PHP versions, as I am running 5.4.4 locally and the server was 5.3. After upgrading the server to 5.4.7, the sidebar is still not appearing. I get no error, just nothing displays.
This is the Widget library code:
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Widgets {
private $_ci;
protected $parser_enable = FALSE;
public function __construct() {
$this->widgets();
}
public function widgets(){
$this->_ci =& get_instance();
}
public function build($view,$data=array()){
$view = get_class($this).'/'.$view;
$subdir = '';
if (strpos($view, '/') !== FALSE)
{
// explode the path so we can separate the filename from the path
$x = explode('/', $view);
// Reset the $class variable now that we know the actual filename
$view = end($x);
// Kill the filename from the array
unset($x[count($x)-1]);
// Glue the path back together, sans filename
$subdir = implode($x, '/').'/';
}
$widget_view = APPPATH.'widgets/'.$subdir.'views/'.$view.EXT;
if(file_exists($widget_view)){
$widget_view = '../widgets/'.$subdir.'views/'.$view.EXT;
if($this->parser_enable){
$this->_ci->load->library('parser');
return $this->_ci->parser->parse($widget_view,$data,TRUE);
}
else{
return $this->_ci->load->view($widget_view,$data,TRUE);
}
}
return FALSE;
}
public function __get($var) {
static $ci;
isset($ci) OR $ci = get_instance();
return $ci->$var;
}
}
Does anything jump out that could cause it not to display?
Is there anything I should be looking at to make it compatible, such as server modules? What on the server could be affecting this?
EDIT:
I have the widgets residing in the following path:
/public_html/application/widgets/recent_news/views/view.php
The $widget_view = 'widgets/'.$subdir.'views/'.$view.EXT;
variable is returning widgets/Recent_news/views/view.php
which is getting passed to:
if(file_exists($widget_view)){
return $this->_ci->load->view($widget_view,$data,TRUE);
}
The application path in $widget_view doesn't seem to be correct on the staging server, so file_exists() returns false and doesn't load the view (which would have an incorrect path anyways).
I just can't seem to make it read the correct path, any suggestions?
If it's a staging server, go into the php.ini file and set
error_reporting = E_ALL | E_STRICT
display_errors = On
This will output whatever errors it finds so you can debug it.
Ended up just needing to subdir = strtolower($subdir);
Thanks for the help everyone
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.