views:

59

answers:

1

Hi,

I'm working on a CMS with Widgets. On my localhost the followong code works perfect, but I have no idea what I'm doing wrong ... The neede files exist, I think and I get no error message. As far as I can see, the error occurs in the one before last line of code and I get no error message.

$view = new Zend_View();
$view->setScriptPath(APPLICATION_PATH . '/../public/websites/' . My_Cookie::get('alpha_key') . '/views');
$view->headScript()->appendFile($vervang['conf']['jqueryJS']);
$view->headLink()->appendStylesheet($vervang['conf']['jqueryCSS']);
$view->class = $pluginExtraFinal;
$view->vervang = $vervang['data'];
$view->moduleName = $moduleName;
$parsed =  $view->render($vervang['conf']['viewFile']);
$inhoud = str_replace($plugin, $parsed, $inhoud);

Is there a way to troubleshoot this code? How can I get an error message? What can be wrong?

Any suggestions please?

A: 

Step 0) Turn on error reporting with error_reporting(E_ALL|E_STRICT);

Step 0.5) Check your server log for php errors

Step 1) Conclude where the error resides in your script by
- commenting out every line, uncomment them back again one line at the time, starting from the top
- replace all parameters in method calls into variables, which you var_dump() to check the content is correctly filled in:

$view = new Zend_View();
$script_path = APPLICATION_PATH . '/../public/websites/' . My_Cookie::get('alpha_key') . '/views';
var_dump($script_path); // is it correct? ok, continue with the next one
$view->setScriptPath($script_path);
...

Step 2) Now that you've checked your code for loopholes on both development and production servers, you should check versions of files, ZF included; server settings; phpinfo() etc

chelmertz
This reminded me I need to setup the debugger on my machine again :)
Goran Jurić
Yeah, manually debugging is not the best time spent.
chelmertz
All lines work perfectly, except: $parsed = $view->render($vervang['conf']['viewFile']);Afte this I even can't do a dump ... nothing happens ... Any suggestions?
koko
@koko have you tried any of the Steps above?
Gordon
@koko what does `$vervang['conf']['viewFile']` spell out to? And where is your `Zend_View::setScriptPath()` pointing?
chelmertz
Hi all, I did the steps above (@Gordon) and finally, after a lot of searching, found the error was in the route.@chelmertz That points to the view that has to be rendered. We work with widgets in the content (text) of a page. Every widget has to be rendered.
koko