Welcome Guest, Not a member yet? Register   Sign In
Help with Phil Template library
#1

[eluser]james182[/eluser]
I am trying to get my navigation working with phil sturgeons template library. i have followed the steps he's provided and the template works, but not my nav. Could i get help to solve this. Thanks

Here is my model, view, and controller.

MY_Controller:

Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');

class MY_Controller extends Controller
{
    function __construct()
    {
        parent::Controller();
        $this->load->model('navigation');
        
        $this->template->enable_parser(FALSE);
        
        $this->data['nav_list'] = $this->navigation->get_nav();
        
        $this->template->set_partial('header', 'partials/header_view');
        $this->template->set_partial('sidebar', 'partials/sidebar_view');
        $this->template->set_partial('footer', 'partials/footer_view');
        
    }
}

/* End of file MY_Controller.php */
/* Location: ./application/libraries/MY_Controller.php */


Header_view.php:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;&lt;?php echo $template['title']; ?&gt;&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

<div id="nav-wrapper">
    <ul>
        &lt;?php foreach($nav_list as $key => $value): ?&gt;
        <li>&lt;?php echo $value; ?&gt;</li>
        &lt;?php endforeach; ?&gt;
    </ul>
</div>


Navigation Model:

Code:
&lt;?php defined('BASEPATH') OR exit('No direct script access allowed');


class Navigation extends Model
{
    function __construct()
    {
        parent::Model();
    }
    
    function get_nav()
    {
        $query = $this->db->get('tbl_nav');
        return $query->result();
    }
}



/* End of file Navigation.php */
/* Location: ./application/models/Navigation.php */
#2

[eluser]techgnome[/eluser]
Don't have any experience with that template system... but at first glance, it looks to me that you're not passing your nav_list to the views properly... you simply load the table into $this->data['nav_list'] but then don't do anything more with it.

-tg
#3

[eluser]Phil Sturgeon[/eluser]
That is nowhere near how the Template library works. check out the documentation:

http://philsturgeon.co.uk/demos/codeigni...youts.html




Theme © iAndrew 2016 - Forum software by © MyBB