Welcome Guest, Not a member yet? Register   Sign In
Not loading the constructor
#1

[eluser]Unknown[/eluser]
Hi all.

First, I would like to introduce myself. I'm a programmer from Croatia. A little bit young, but been around for 3 years now. I have done some sites using CodeIgniter (my blog, a little company site) etc.

Now, to the problem. Yesterday I started a new project, and ... well, wanted to use CodeIgniter Smile

I have created a small model called Template:
Code:
<?php

class Template extends Model {

    public function Template() {
    
        parent::Model();
    
    }

    public function insert($content,$title = 'undefined') {
    
        $template_vars = array (
            'sub_ => $title,
            'design => base_().'design/',
            'content' => $content
        );
    
        $this->load->view('template.php',$template_vars);
    
    }
    
}

?>
(I autoload the model)

So that you can understand my problem, let's look at a simple controller:

Code:
<?php

class Start extends Controller {

    public function Start() {
    
        parent::Controller();
        
        $this->_template();
    
    }
    
    public function _template() {
        
        $content = $this->load->view('models/start.php','',true);
    
        $this->template->insert($content,'start page');
    
    }

}

?>

So the theory now Smile I've created files template.php, models/start.php .
When I access the url /index.php/start I get a 404 error.

I've renamed the function _template() inside the controller to template(), and when accessing the url /index.php/start/template, I get the contents of the models/start.php twice (because of the template() function been called twice (inside the constructor and also manually)).

But, when accessing the url /index.php/start I get nothing..

Maybe it is a simple error, but I can't find it. Help Smile

Sorry for my bad english
#2

[eluser]Unknown[/eluser]
Solved,

dear God, the index() function Smile need some sleep
#3

[eluser]Derek Allard[/eluser]
Nitko, I've been making silly mistakes like that all week. I'm sorry to say that it won't go away no matter how much longer you program Wink




Theme © iAndrew 2016 - Forum software by © MyBB