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

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 {
function Project(){
    function index(){
        $data['title'] = "Project Management";
        $data['subtitle'] = "| Nothing more, nothing less";
        $data['query']= $this->db->get('projects');
    function p_list(){
        $data['query']= $this->db->get('projects');

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:

<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;
            &lt;?php endforeach; ?&gt;

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
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!


[eluser]Jamie Rumbelow[/eluser]
Are you making sure you run the query for the projects on the client controller? Make sure that you are querying the right table.

Thanks for helping, I was sure that I was calling that query, and it really had me stumped, but thanks to your reply, it got me thinking.
It was in fact an error on my part (no surprise there then Wink in the fact that I was doing the $this->load->view bit before the $this->db->get bit.

Thanks for pointing me in the right direction.

Theme © iAndrew 2016 - Forum software by © MyBB