|
|||
|
I've listed my step by step instructions on how I setup the application environment here with screenshots.
Application Setup Steps Thanks for your help. ![]() If you need more details, let me know. |
|
|||
|
Never seen someone supply so much information before...perfect...will make it a bit easier(hopefully), to find the error.
What I can see now is that you are missing the display.phtml and index.pthml file. Inside the "include" directory create a directory with the name "views" in that folder create a folder with the name "scripts". In the "scripts" folder create two folders with the name "index" and "news". Within the "index" directory create the file "index.phtml" and in the "news" directory create "default.phtml" and "index.phtml" All the above is the get the Zend Framework to work properly...I have never used the smarty template so can't say anything about that. You can find the proper directory structure here. Summary What I'm trying to explain above is that in your "views/scripts" folder, you will need a folder for each controller you have. If you have a FooController, you will need a "foo" directory in the "views/scripts" folder. If you have a BarController you will need a folder named "bar" in the "views/scripts" folder. Now let's take it a step further. For each Action in your Controllers you will need a .phtml (php+html, non-official filextension, just commonly used). With the actions name, indexAction will need a index.phtml and your displayAction will require a display.phtml in the correct directory. Last edited by Holmen : 01-28-2008 at 04:03 PM. |
|
|||
|
Quote:
![]() |
|
|||
|
Quote:
I am having the same problems (appearently using the same book )i did figure out something. The problem lies in the CustomControllerAction.php in the controllers (ie IndexController.php etc) you extend to the CustomControllerAction (class IndexController extends CustomControllerAction) which give the fatal error. if you replace CustomControllerAction and use the Zend_Controller_Action instead it does work as intended. ( class IndexController extends Zend_Controller_Action) i know this isnt the valid way to do, and dont ask me why extending the customcontrolleraction doesnt work. i am lacking the indepth php knowledge for that ![]() but perhaps some other people know what is wrong with the CustomControllerAction.php (code below) Code:
<?php
class CustomControllerAction extends Zend_Controller_Action
{
public $db;
public function init()
{
$this->db = Zend_Registry::get('db');
}
}
?>
|
|
|||
|
Nothing wrong with the code you posted..
But make sure that you have stored something in Zend_Registry 'db' (probably done in bootstrap) And also remove the '?>' from the last line to make sure the problem isn't caused by a trailing whitespace. What book is it that you are reading? A good practice, since ZF is so new and still undergoing a lot of changes, would be to cross-reference everything you read with the online docs. Chances are that whatever is printed in that book is outdated. The same goes for most tutorials that can be found online. Last edited by Leif.Högberg : 02-08-2008 at 12:01 PM. |
|
|||
|
Quote:
![]() The book is: Practical Web 2.0 Applications with PHP ( Practical Web 2.0 Applications with PHP, by Quentin Zervaas (ISBN 1590599063) ) to confirm what you are asking about the registry-db thingy see code below. when i get home i will look if i have a trailing ?> or not, and if it makes the difference. bootstrap: (line 21/22) PHP Code:
|
|
|||
|
Hello,
This example comes from the Web 2.0 Applications with PHP book, I tried this and had the same problem, the solution is simple, just add: $controller->setParam('noViewRenderer' , true); after the ::getInstance(); and it works. Don't ask me why, I'm pretty new to this, but the errors are gone, at least in my case. Hope it works for you. |
|
|||
|
I went through the same issue. The example in the book is extending the framework to implement Smarty templates instead of using the Zend viewer. Search "Zend_Controller_Action_Helper_ViewRenderer" in the Zend Manual for more info. I had to stop with the book and do a few simpler tutorials that used the default views. The book made more sense once I had a general idea what I was extending.
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|