Welcome Guest, Not a member yet? Register   Sign In
How to pass variables from a model to another model?
#1

[eluser]Juan Velandia[/eluser]
Hello every one.

I've working on this for a while, but i decided to ask for help. I'm working on this site menu:

http://190.146.3.147/assa-seguros.com/

I have a database with:

cms_article
cms_section

they both have a field url_section wich works as an ID for the table cms_section. and I need to show the name of the article that belongs to the section in the menu: here's the model to get the sections
Code:
function show_section()
    {

        $lang='ES';
        $this->db->select('name');
        $this->db->where('lang',$lang);
        $query = $this->db->get('cms_section');
        return $query->result();
        
    }
here's the model to get the articles belonging to the sections
Code:
function get_article_list()

    {

        $lang='ES';

        $this->db->select('cms_article.name');
        $this->db->from('cms_article');
        $this->db->join('cms_section', 'cms_article.url_section = cms_section.url_section');
        $this->db->where('cms_article.lang',$lang);
        $this->db->where('cms_section.url_section',??????????????????);
        $query = $this->db->get();
        return $query->result();
        

    }
and here's the view

Code:
<ul class="menu" id="menu">
  &lt;?php foreach ($show_section as $row1): ?&gt;
     <li>&lt;?echo $row1->name?&gt;
        <ul>
          &lt;?php foreach ($article_list as $row2): ?&gt;
             <li><a href="#" class="sub">&lt;?echo $row2->name?&gt;</a>
            </li>
          &lt;?php endforeach; ?&gt;
        </ul>
    </li>
  &lt;?php endforeach; ?&gt;
</ul>

I think need to pass the url_section from the first model to the second to discriminate wich article bolong to wich section, but I I'm sotocked here, i only get to show all the records from cms_article

Any ideas?? thanks a lot in advance!


Messages In This Thread
How to pass variables from a model to another model? - by El Forum - 07-17-2010, 11:55 AM
How to pass variables from a model to another model? - by El Forum - 07-17-2010, 06:34 PM
How to pass variables from a model to another model? - by El Forum - 07-17-2010, 07:21 PM
How to pass variables from a model to another model? - by El Forum - 07-18-2010, 12:41 PM
How to pass variables from a model to another model? - by El Forum - 07-18-2010, 01:49 PM
How to pass variables from a model to another model? - by El Forum - 07-19-2010, 06:24 AM
How to pass variables from a model to another model? - by El Forum - 07-19-2010, 08:01 AM
How to pass variables from a model to another model? - by El Forum - 07-19-2010, 08:17 AM
How to pass variables from a model to another model? - by El Forum - 07-19-2010, 03:00 PM
How to pass variables from a model to another model? - by El Forum - 07-20-2010, 09:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB