views:

29

answers:

1

When Ive created a new controller, ie in this case Authenticate, Ive also created the folder and file application/views/scripts/authentication/index.phtml

Not a problem when hitting the url http://dev.local/authentication/ but when calling any action ie http://dev.local/authentication/login, I get the error below.

Message: script 'authentication/login.phtml' not found in path (C:\Sites\application\views\scripts\)

Regardless of any changes Im going to make to the login action it shouldnt automatically ask for a new page right? or am I wrong?

A newbie zend programmer here.

Thanks

+1  A: 

By default, each action requires its corresponding view (phtml page). If you want to disable a view/layout for a given action, you can use the following code :

$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);

EDIT in response to the comment:

I usually don't need to do this, because the actions I have that don't need a view script are redirected/forwared to other actions. For example, once your user is authenticated (i.e. when /authentication/login succeeds), you can redirect him to the home page (or whatever page he was trying to access. Similarly, if the login failed, I simply set an error message in the view and forward to the action that shows the login form.

The only actions for which I use the above code is for actions that are typically called using AJAX and that output some JSON code, for example.

Wookai
Superb answer! thanks so much
bluedaniel
another thing... I see on tutorials that they always seem to have this running on default, ie they dont copy and paste this code in every action, is it worth turning off globally and how can i do it?
bluedaniel
No problem, glad to help a fellow zend framework user. I updated my answer above to answer your questions.
Wookai
Cheers, just picked up Zend a day or two and its a steep learning curve at first!
bluedaniel
True. While the Zend_Tool utility is really great to have a sample website running in no time, some aspects are hard to get. I strongly recommend to follow the whole quickstart guide (http://framework.zend.com/manual/en/learning.quickstart.intro.html) and to use the Zend_Layout: it's really great!
Wookai
yeah im already using the zend layout, excellent stuff, I want to code everything from scratch, ditch the tool for the moment. Ive got another question if your game..about sessions on wamp?
bluedaniel