Hi all,
maybe it's a newbie question, but I still can't find out why this happens..
I managed to create simple IndexController and ErrorController, but I can't
make ZF to render another script than index.phtml from indexAction of
IndexController.
What I need is to show a login form in case that user is not logged in.
Here's the code:

<?php
/*
 * Default controller for back-end
 * 
 * Shows the back-end's homepage in case that user is logged in.
 * Otherwise, it shows the login page. 
 * @author Richard VĂ­tek <[EMAIL PROTECTED]>
 */
class IndexController extends Zend_Controller_Action
{
        /**
         * Initialization - invoked in constructor.
         */
        public function init ()
        {
                //$this->view->addHelperPath('../application/views/helpers',
'Venturia_View_Helper');
                $this->view->wwwroot = $this->_request->getBaseUrl();
        }


        /**
         * The default action - show the home page.
         */
        public function indexAction ()
        {
                echo 'Index action called.';
                $oUserSession = new Zend_Session_Namespace('user');
                $oUserSession->id = 1;
                unset($oUserSession->id);
                //print_r($_SESSION);
                //echo $this->_request->getHeader('accept-language');
                $this->view->iUserId = $oUserSession->id;
                $this->view->sBaseUrl = $this->_request->getBaseUrl(); //.
$this->_request->getPathInfo();
                
                //user is not logged in => show login page
                //if (!isset($oUserSession->id))
                //{
                        //echo 'Script Path:' . 
$this->view->getScriptPath('login.phtml');
                        $this->view->render('login.phtml', null, false);
                        //echo 'Login';
                //}
        }
}
?>

The render() method does not seem to be working as claimed in manual.
a) script filename must be set with extension too
b) AFAIK, login.phtml should be looked for in
somepath/views/scripts/index/login.phtml, but it is looked for directly in
somepath/views/scripts/ directory (controller's name not used, no matter how
the 3rd parameter of render() method is set)
c) and the worst, even when set unconditianally as seen in code above, it
still renders somepath/views/scripts/index/index.phtml script instead of
login.phtml

Can anyone explain me please why this happen and even better how to make it
work?
Thank a lot
-- 
View this message in context: 
http://www.nabble.com/Strange-Zend_View-%3Erender%28%29---tf4872248s16154.html#a13941930
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to