Welcome Guest, Not a member yet? Register   Sign In
How to use functionality of another controller (render its view inside mine)?
#1
Question 

Hi, everybody!
I need to render the login form of an authentication library inside my own view. It is not possible to simply load view 'login_form', because there are many parameters it needs. That job is performed by corresponding function of the auth controller. But it became a disaster trying to load that controller from inside my view!
load_class(...) says it cant find the class, whatever paths I tell it...
require(...) leads to the chain of 'undefined property' (hadr to figure out the reasons)...
PHP Code:
<div id="userbar">
 <?
php if ($this->tank_auth->is_logged_in()): ?>
 Hi, <strong><?=$this->tank_auth->get_username().' ('.$this->tank_auth->get_user_id().')';?></strong>!<br />
 <a href="/index.php/auth/logout">Logout</a>
 <?php else: ?>
 <?php  // all these doesnt work, causes chain of errors
 
require_once('application/controllers/auth.php'); // success!
 
$this->AuthController = new Auth// success!
 
$this->AuthController->login(); // this should render a login form here, but errors happen inside auth library/controller
 
?>
 <?php endif ?>
 </div> 

What is the best way to get such things done???
Reply


Messages In This Thread
How to use functionality of another controller (render its view inside mine)? - by Kulavert - 10-12-2015, 10:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB