Welcome Guest, Not a member yet? Register   Sign In
Unable to retrieve data when using Phil Sturgeon's template library set_partial
#1

[eluser]goFrendiAsgard[/eluser]
As stated here : http://philsturgeon.co.uk/demos/codeigni...et_partial
There are 3 parameters of set_partial, the last one is array

So I assume it would be just like $this->load->view('nameOfMyView', $data);

But I think there is something wrong (with my code or with the library)
Code:
//login or logout (different nav_account)
        $login = $this->ion_auth->logged_in();
        $isAdmin = $this->ion_auth->is_admin();
        if($login){            
            $profile = $this->ion_auth->get_user_array();
            $data = array(
                "profile" => $profile,
                "isAdmin" => $isAdmin
            );
            echo var_dump($data); //this one to make me sure there is some data
            $this->template->set_partial('nav_account', 'partials/nav_account_isLogin', $data);
        }
        else{
            $this->template->set_partial('nav_account', 'partials/nav_account_isLogout');
        }
from the var_dump, I receive a good content, which mean that $data["profile"] and $data["isAdmin"] are exists
But I got this message in my browser:
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined variable: profile

Filename: partials/nav_account_isLogin.php

Line Number: 1

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: isAdmin

Filename: partials/nav_account_isLogin.php

Line Number: 3

This is my partials/nav_account_isLogout.php
Code:
Welcome, <?php echo $profile['username'] ?> 

<?php if ($isAdmin){ ?>
<!-- it showed link -->
<?php } ?>

anybody has a clue?




Theme © iAndrew 2016 - Forum software by © MyBB