Welcome Guest, Not a member yet? Register   Sign In
doubt on Dynamic content display
#1

[eluser]amipaxs[/eluser]
hi,

I'm using a horizontal menu in the header. i was requested to generate dynamic submenus only for one of the links, i created the corresponding forms on my cms and tables on the db.

code to display the dynamic submenu in the view:
Code:
[color=blue]
<li><a class="two" href="&lt;?php echo base_url();?&gt;portal/lineas_de_accion">Lines</a>
    <ul>
        &lt;?php
          foreach($submenu as $list){
          echo "<li>".anchor("portal/submenus/".$list['id_lineas'], $list['nombre'])."</li>\n";  
          }
    ?&gt;        
    </ul>
[/color]

to actually load the dynamic submenus, there're about 20 functions in the main controller where i'll have to add the following line of code in order to display dynamic submenus on each page, my question is, Am i using the right procedure??

Code:
$data['submenu'] = $this->MLines->getDynamicSubmenus(); //call model in order to load dynamic submenus

Any suggestions are welcome.
#2

[eluser]BrianDHall[/eluser]
You might consider rigging it to work, if possible, in the constructor using a class variable. I for instance have a $this->data array variable I declare in my controller, and my constructor does some work like checking for login status and loading variable menus for use in my template into the $this->data variable.

Now I just always pass $this->data to my views so I don't have to repeat any code.

As an additional trick, I use some pass by reference assignments in my controller so I can use something like $this->content and it will automatically change the value of $this->data['content'] without me having to worry about remembering to load up $data with everything it needs before passing to a view.
#3

[eluser]amipaxs[/eluser]
thanks man !!

I've been enlightened!




Theme © iAndrew 2016 - Forum software by © MyBB