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

[eluser]james182[/eluser]
Hi i'm new to CI and was wanting help with getting the template to work.

I'm using Ocular Template Libray 2.0, and DX_Auth and have setup the main layout as:
Code:
<?php echo $this->template->block('header', 'partials/header'); ?>

<div id="content-wrapper">
    &lt;?php echo $this->template->message(); ?&gt;
    &lt;?php echo $this->template->yield(); ?&gt;
</div>

&lt;?php echo $this->template->block('footer', 'partials/footer'); ?&gt;
Above locations: views/partials/header.php & footer.php, views/layouts/layout.php

now what i'm trying is to get the header to work on the backend/user (DX_Auth) "page".

which looks like:
Code:
&lt;?php echo $this->template->block('header', 'partials/header'); ?&gt;
&lt;?php
        
        // Show reset password message if exist
        if (isset($reset_message))
            echo $reset_message;
        
        // Show error
        echo validation_errors();
        
        $this->table->set_heading('', 'Username', 'Email', 'Role', 'Banned', 'Last IP', 'Last login', 'Created');
        
        foreach ($users as $user)
        {
            $banned = ($user->banned == 1) ? 'Yes' : 'No';
            
            $this->table->add_row(
                form_checkbox('checkbox_'.$user->id, $user->id),
                $user->username,
                $user->email,
                $user->role_name,            
                $banned,
                $user->last_ip,
                date('Y-m-d', strtotime($user->last_login)),
                date('Y-m-d', strtotime($user->created)));
        }
        
        echo form_open($this->uri->uri_string());
                
        echo form_submit('ban', 'Ban user');
        echo form_submit('unban', 'Unban user');
        echo form_submit('reset_pass', 'Reset password');
        
        echo '<hr/>';
        
        echo $this->table->generate();
        
        echo form_close();
        
        echo $pagination;
            
    ?&gt;
Above location: views/backend/users.php

errors are:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: nav_list
Filename: partials/header.php
Line Number: 14

A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: partials/header.php
Line Number: 14
Below header.php
Code:
<div id="header-wrapper">
    <ul class="nav_list">    
    &lt;?php foreach($nav_list as $key => $value): ?&gt;
        <li><a href="&lt;?php echo base_url(); ?&gt;&lt;?php echo $key; ?&gt;">&lt;?php echo $value; ?&gt;</a></li>
    &lt;?php endforeach; ?&gt;    
    </ul>
</div>

any help would be great.
#2

[eluser]Dennis Rasmussen[/eluser]
The controller for your first (working) file sets the data for $nav_list (used in the header).
The second example you've provided apparently doesn't have $nav_list applied to it from the controller.

Does that make sense?
Anyway there's no data for the header.php file in the 2nd example.
It's missing.




Theme © iAndrew 2016 - Forum software by © MyBB