Welcome Guest, Not a member yet? Register   Sign In
Function parameter included in load
#1

[eluser]Martin Rusev[/eluser]
Hello Everybody,

I am pretty new to Codeigniter.( In the moment i am developing my second project )

I want to create function that loads php files dynamicly and i am wondering is it possible.

To illustrate better what i mean, here is the real function :
Code:
function projects($project_name)
    {    
        $this->load->view('includes/header', $data);
        $this->load->view('work/projects'.$project_name , $data);
        $this->load->view('includes/footer');
    }

Is this possible?
There is no database in this project and i am using only views and controllers

Thank you in advance for your responses Smile
#2

[eluser]Martin Rusev[/eluser]
Problem Solved
Code:
function projects($project_name)
    {    
        $current_project = 'portfolio/projects_2008/'.$project_name;
        $this->load->view('includes/header', $data);
        $this->load->view($current_project , $data);
        $this->load->view('includes/footer');
    }

It was just easy PHP logic Smile
#3

[eluser]Pygon[/eluser]
I think your problem was here:
Code:
$this->load->view('work/projects/'.$project_name , $data);

You were missing the "/" that denoted projects was a directory, so you were actually calling:

Code:
projects(cars);
>>> $this->load->view('works/projectscars',$data);
#4

[eluser]Martin Rusev[/eluser]
And that was a problem too Smile




Theme © iAndrew 2016 - Forum software by © MyBB