Welcome Guest, Not a member yet? Register   Sign In
Dynamic content in the template file
#11

[eluser]Kamy[/eluser]
test Controller:

Code:
public function index()
    {
    $data['sidemenu'] = 'Whatever';
        $this->load->vars($data);
        $this->load->view('test_view');  
    }

test_view.php:

Code:
<?php echo $sidemenu;?>
<p>
I am a Web Developer and IT consultant with over 12 years of experience , I'm pretty versatile in the field of Web Development and Website management.</p>

If I browse to http://localhost/index.php/test it works !

But when I try to implement within the template file:

Code:
&lt;?php  $this->load->view('test_view');    ?&gt;

I get the error
#12

[eluser]InsiteFX[/eluser]
Show your Template file

InsiteFX
#13

[eluser]Kamy[/eluser]
template
Code:
&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;


<div id="logo"> </div>  

<div id="tabsI">
<ul>
&lt;?php foreach($nav_list  as $i => $nav_item): ?&gt;
                <li &lt;?  if ($nav==$i){ ?&gt;  id="current" &lt;? } ?&gt; >&lt;?= anchor($nav_item, '<span>'.$i.'</span>') ?&gt;</li>
&lt;?php endforeach ?&gt;
</ul>
</div>

<h1>&lt;?= $title ?&gt;</h1>

<div id="content"> &lt;?= $contents;?&gt;</div>

<div id="side_menu">
&lt;?php $this->load->view('test_view');?&gt;
</div>

&lt;/body&gt;
&lt;/html&gt;
#14

[eluser]Kamy[/eluser]
I really need a help with this, any ideas?
#15

[eluser]InsiteFX[/eluser]
$i is not being incremented so it will always contain the same value of $nav_item!
Code:
&lt;?php foreach($nav_list  as $i => $nav_item): ?&gt;
                <li &lt;?  if ($nav==$i){ ?&gt;  id="current" &lt;? } ?&gt; >&lt;?= anchor($nav_item, '<span>'.$i.'</span>') ?&gt;</li>
// you may need to re-code this for error checking!
$i++;
&lt;?php endforeach ?&gt;

InsiteFX
#16

[eluser]Kamy[/eluser]
Dude, that has nothing to do with my problem !

$i does not need to get incremented in that case.......




Theme © iAndrew 2016 - Forum software by © MyBB