Welcome Guest, Not a member yet? Register   Sign In
Loading controllers from a view
#1

[eluser]heaversm[/eluser]
Hi - sorry - I'm traditionally a Flash programmer and very new to the code igniter way of thinking. In flash, you build a class with a bunch of functions, and if you want to call a function, you just put that function name into your code wherever you want it executed. Does that not work in CodeIgniter? I'm trying not to load a ton of code into my index function, so I want to put it into multiple functions, but I want all those functions to load when the user accesses my URL. For example, say I have a controller called Portfolio. I have two functions:

Code:
function index(){
    $data['main_content'] = 'portfolio_home';
    $this->load->view('portfolio',$data
}

function listProjects(){
    $this->load->library('table');
    $query = $this->db->query("
        SELECT clients.client, project_list.project, project_list.role, project_list.url
        FROM clients, project_list
        WHERE clients.id = project_list.client_id
        GROUP BY clients.client, project_list.project
        ");
        
    echo $this->table->generate($query);
}

How can I specify in my view somewhere to execute listProjects()? If I put this into the index function, I can't specify where the table is generated. Plus, as development goes on, I get a really long index function. But if I keep it as a separate function, I have to load a different view entirely in order to see the result. Sorry, I know it's a remedial question, but nothing I've read has been able to explain this in a way that makes sense to me yet. Thanks in advance,

Mike


Messages In This Thread
Loading controllers from a view - by El Forum - 11-23-2010, 07:40 AM
Loading controllers from a view - by El Forum - 11-23-2010, 07:47 AM
Loading controllers from a view - by El Forum - 11-23-2010, 07:53 AM
Loading controllers from a view - by El Forum - 11-23-2010, 08:04 AM
Loading controllers from a view - by El Forum - 11-23-2010, 08:43 AM
Loading controllers from a view - by El Forum - 11-23-2010, 09:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB