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

[eluser]Taff[/eluser]
I've spent quite some time browsing the forum, bookmarking things that I will probably need on my way, but haven't been able to find a solution to this, which either means I don't know what I'm on about, or I have no idea what I'm on about.

I have built a little class based on the blog tutorials to create names for projects.

class Project extends Controller {
Code:
function Project(){
        parent::Controller();
        $this->output->enable_profiler(TRUE);
        $this->load->scaffolding('projects');
        $this->load->helper('url');
        $this->load->helper('form');    
    }
    function index(){
        $data['title'] = "Project Management";
        $data['subtitle'] = "| Nothing more, nothing less";
        $data['query']= $this->db->get('projects');
        $this->load->view('project_display',$data);
    }
    function p_list(){
        $data['query']= $this->db->get('projects');
        $this->load->view('project_list',$data);
    }
}

In particular I like my project_list view which I'm embedding into my project_display view and works very nicely without me having to repeat the code anymore.

My next step was to make a client class for all my client information. This client class is essentially very similar and allows me to output their data in a list using my client_display view:

Code:
<div id="normalcontent">
        <h3>Clients</h3><p>&lt;?php echo anchor('client/add', 'Add a new client' , array('title' => 'Click to add a new company')) ?&gt;</p>    
        
                &lt;?php foreach ($c_query->result() as $row): ?&gt;
                <div style="width:50%;float:left;">
                <h4>&lt;?php echo anchor('clients/'.$row->client_id, $row->name , array('title' => 'Click to edit '.$row->name)); ?&gt;</h4>
                <p>Address &lt;?php echo $row->address; ?&gt;<br />
                City &lt;?php echo $row->city; ?&gt;<br />
                State &lt;?php echo $row->state; ?&gt;<br />
                Zip &lt;?php echo $row->zip; ?&gt;<br />
                Country &lt;?php echo $row->country; ?&gt;<br />
                URL&lt;?php echo $row->url; ?&gt;<br />
                Phone&lt;?php echo $row->phone; ?&gt;<br />
                Fax &lt;?php echo $row->fax; ?&gt;</p>
                &lt;?php echo anchor('clients/'.$row->client_id, 'Edit' , array('title' => 'Click to edit '.$row->name)); ?&gt;
                </div>
            &lt;?php endforeach; ?&gt;
        
        
</div>

I am now at a total loss as to how I can embed my project_list into this view. Everything I have tried tells me it can't find query or mad attempts such as
$projects=$this->Projects->p_list();
have had no avail.

As mentioned at the beginning this is most probably due to my lack of terminology and a total grasp of the pattern, and maybe I should be approaching this is a different manner?

Thanks for any pointers!

Taff


Messages In This Thread
Loading a view from a different class. - by El Forum - 04-20-2008, 08:58 AM
Loading a view from a different class. - by El Forum - 04-20-2008, 10:50 AM
Loading a view from a different class. - by El Forum - 04-20-2008, 11:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB