[eluser]dezynworks[/eluser]
The server seems to be set up correctly. If there were a server configuration problem, I would expect the whole site to be down, not just the galleries. There are two other controllers used on the site and they work fine. The only real difference is neither one loads a model. The Gallery controller is being called, it's just not calling the right action function. Going to /gallery/ should be calling the index() function in the Gallery controller, but for some reason I cannot fathom, the view() function is being called instead.
I did double check case and the only problem I noticed is, according to the User Guide, a model should be loaded by its class name, not its file name. IOW $this->load->model('Gallery_model'),
not $this->load->model('gallery_model'). I did fix this, but it did not make a difference.
I'm getting two errors when I try to access the gallery index page. The first a database error because it is calling the view function and not the index function so the parameters the query is looking for are not there.
The second error is a "Call to a member function on a non-object" error. This one I don't understand, because this line is calling a function in a model (marked w/ ** below). I would expect more parameter based errors not the inability to even access the model. Note: the Gallery model loaded in the constructor is accessible, just not the Photo model loaded in the view function. I don't know if this is another symptom of whatever is causing the wrong action function to be called or not.
This is my Gallery controller:
Code:
class Gallery extends Controller
{
function Gallery()
{
parent::Controller();
$this->load->model("Gallery_model");
}
function index()
{
$dud = new stdClass();
$dud->id = 0;
$data["gallery"] = $dud;
$data["gallery_menu"] = $this->Gallery_model->fetchAllGalleries();
$data["galleries"] = $this->Gallery_model->fetchCurrentGalleries();
$data['content_for_layout'] = $this->load->view( "galleries/index",$data, true );
$data['css_for_layout'] = 'galleries';
$data['title_for_layout'] = 'QUAC Photo Galleries';
$this->load->view( "default_layout", $data );
}
function view( $gallery_id )
{
$this->load->model( "Photo_model" );
$gallery = $this->Gallery_model->findById($gallery_id);
$data["gallery"] = $gallery;
$data["gallery_menu"] = $this->Gallery_model->fetchAllGalleries();
**$data["photos"] = $this->Photo_model->findByGalleryId( $gallery_id );
$data["content_for_layout"] = $this->load->view( "galleries/view", $data, true );
$data['scripts_for_layout'] = 'jquery.lightbox';
$data['css_for_layout'] = array('galleries','jquery.lightbox');
$data['title_for_layout'] = 'QUAC Photo Galleries: '.$gallery->name;
$this->load->view( "default_layout", $data );
}
}
And my Photo model:
Code:
class Photo_model extends Model
{
function Photo_model(){
parent::Model();
}
function findByGalleryId( $gid ){
$this->db->where( "gallery_id", $gid );
$cursor = $this->db->get("photos");
return $cursor->result();
}
}
I've looked through my config files, and I don't see anything obviously wrong. Neither of these models is autoloaded.
Thanks for your feedback. Any other ideas for what I need to check?
-Sean