How can I troubleshoot plugins?
When I use print_r or var_dump to show variables,
nothing is shown... I guess because it is the manager...
I have checked the log, but there is nothing there...
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
Quote from: charliez at Oct 14, 2009, 06:04 PM
How can I troubleshoot plugins?
When I use print_r or var_dump to show variables,
nothing is shown... I guess because it is the manager...
I have checked the log, but there is nothing there...
There are ways to do it, but I can never remember them so I usually just write the stuff to a text file.
$fp = fopen('c:/test.txt', 'w+');
fwrite($fp, $variable);
fclose($fp);
Nope, it does not work... I am developing in the server
and it gives me an error that the parser does not give
permission to fopen a file...
there has to be another way!
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
Any help on the topic?
I have tested and troubleshooted using a snippet as far as I can go,
but know I want to do the Plugin part... any ideas?
TIA
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
Quote from: charliez at Oct 14, 2009, 07:58 PM
Nope, it does not work... I am developing in the server
and it gives me an error that the parser does not give
permission to fopen a file...
there has to be another way!
Write the file in a directory you have write access to?
I’m definitely no expert in this department. Sometimes you can put the debugging message in the event’s output (assuming the output is displayed somewhere).
Here’s what to do in Revo:
http://modxcms.com/forums/index.php/topic,39829.msg240823.html#msg240823.
In Evo, try:
webAlert(’message’);
$modx->webAlert(’message’);
error_log(’message’);
die(’message’);
BTW, sometimes print_r() doesn’t work becuase the variable you’re sending it is an object rather than an array.
Thanks Bob, I will try that...
your link gives me this:
An Error Has Occurred!
The topic or board you are looking for appears to be either missing or off limits to you.
And I am logged in...
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
Quote from: charliez at Oct 19, 2009, 01:42 PM
Thanks Bob, I will try that...
your link gives me this:
An Error Has Occurred!
The topic or board you are looking for appears to be either missing or off limits to you.
And I am logged in... 
Sorry, it’s in a restricted area of the forums. Here’s the gist of it:
Use:
After changing the "log target" via $modx->setLogTarget($target), to "ECHO". By default, the target is a file target definition which points at the core/cache/logs/error.log. The setLogTarget() function returns the current target so you can set it back once you are done redirecting to another target temporarily.
I haven’t tried this in Evo, but it may work.
[Update] I just checked and Evo doesn’t appear to have setLogTarget().
Thanks Bob, I think that between webAlert and logEvent
I have a way to see what is going on in the plugin...
thanks again Bob...
Carlos
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
Quote from: charliez at Oct 19, 2009, 04:58 PM
Thanks Bob, I think that between webAlert and logEvent
I have a way to see what is going on in the plugin...
thanks again Bob...
Carlos
Don’t thank me until it works.