Home » Topics » Pods 1.x » post-save helpers, helper debugging, including helpers as file and other questions
post-save helpers, helper debugging, including helpers as file and other questions
This topic contains 2 replies, has 1 voice, and was last updated by Kamil Grzegorczyk (Owi) 2 years, 3 months ago.
-
AuthorPosts
-
February 22, 2011 at 1:48 pm #165223
Hello,
I have few questions which i didnt find an answer for by looking through almost everything I was able to find in documentation or forums.
- Can i call some functions from functions.php or from some plugin inside of helpers or can i just include them?
- Can I call function as a post-save helper from pods UI function? Like adding some parameter to $object->ui which will fire function on save (function not pod helper)?
- Is there a way to see php errors generated by helpers? Debug it somehow using functions like vardump, print_r?
I would like to build a little bit complicated post-save helper which updates another pod and generates some logs. Its very hard to do it without some response from pods. For example if i type die() inside of a helper I would expect some error displayed in admin area (or even just blank page) but of course nothing happens (for example pod is not saved but page works fine). i know that this is because pods uses ajax heavily but is there a way to help in developement process by swicthing off some things?
I would like to now if somebody found some solution for such situation, got around that.
The only thing which comes to my mind is trying to play with pods cms plug but I want to find easiest way to not interfere with pods itselfBest Regards
KamilFebruary 22, 2011 at 2:12 pm #165224I managed to display some debug errors using such solution:
123456<?php//by using TRUE parameter all pods data contained in $columns is returned to $data variable$data = print_r($columns, TRUE);//displaying data as a JS pop-updie('<e>'. $data );?>Maybe this will help someone who would like to debug something also (of course when they are adding pods through admin area)
February 23, 2011 at 1:40 am #165225OKay I found a solution for another thing – I played around Pods CMS and UI code (ui is just terrible, no comments, no good code formatting but I understand that it is not some main plug).
I would like to share solution to help other ppl having such ideas
Basically whole process is very easy.
- Create a file inside our custom plugin directory (i presume that You are using PODS UI to create some custom environment) called helper.php which contains Your function declarations or other stuff
-
Next we create post-save helper and assigning that to particular POD
-
Now we can work on our helper inside our favourite IDE like Dreamveawer or whaever You prefer.
-
As pods heavily uses ajax to call pods api methods in order to see php errors please use Firebug addon to firefox, switch to console tab – You can view php error in response tab of AJAX call.
helper.php
1234<?php//add path to Your plugin dirrequire_once(ABSPATH . '/wp-content/plugins/YOUR-PLUGIN-DIR/helper.php');?>If You dont want to play with firebug go to pods/ui/js/pods.ui.js and change this
1234567function is_error(msg) {if ("<e>" == msg.substr(0, 3)) {alert(msg.substr(3));return true;}return false;}to this
1234567891011function is_error(msg) {if ("<e>" == msg.substr(0, 3)) {alert(msg.substr(3));return true;}if((msg.search(/parse error/i) != -1) || (msg.search(/fatal error/i) != -1)){alert(msg)return true}return false;}And all php parse errors will be prompted as an alert
Those methods should work with every type of helper. It should be helpful if You are trying to build some more complicated stuff.
Of course Im awaiting for responds from more experienced pods users – maybe Im overcomplicating everything
-
AuthorPosts
You must be logged in to reply to this topic.