views:

29

answers:

2
+1  Q: 

PODSCMS + jQuery

Hi, I am modifying a theme and pulling data out of my PODS tables. I also have a custom DBTOXML.php file which is called from index.php using an AJAX call. Since this is a custom file that I put into my wordpress theme, it can't seem to find my Pod class and so I am not able to pull data out of my PODS tables. Any idea how I can make that 'DBTOXML.php' work with PODS?

Here is the complete code for DBTOXML.php

<?php
$rwhdata = new Pod('rainwater');
$p = $rwhdata->fetchRecords();
$dom = new DOMDocument("1.0");
$node = $dom->createElement("Markers");
$parnode = $dom->appendChild($node);
while ($p->fetchRecord()) {
    $node = $dom->createElement("marker");  
    $newnode = $parnode->appendChild($node); 
    $locString = $p->get_field('location');
    list($latitude,$longitude)=split(',',$locString);
    $newNode->setAttribute("latLocation",$latitude);
    $newNode->setAttribute("longitude",$longitude);

}
echo $dom->saveXML();
?>

and this is the jquery call...

$.ajax({
                url:'<?php echo bloginfo('template_url').'/DBTOXML.php';?>',
                type:'POST',
                data:"",
                success:function(results)
                {
                    //Some work here

                }
                });
A: 

If the one you've posted is your entire DBTOXML.php code, it won't find your class because you haven't included the necessary PODS files. Take a look at your main theme page code to see which pods' files are included and try to add them to your page...

mamoo
that's the thing... in my index.php i have stripped out all the default code and put in my own HTML and PHP..and there PODS works fine..
Sharath
Pods methods and API should be accessible through out any instance of your theme/plugin development. They intended it to be that way. Try moving your code to your functions.php file and see if that works.
hsatterwhite
@hsatterwhite - tried it using call_user_func() , am still getting error..please help! urgent and desperate!
Sharath
@Sharath Try their Chat. Scott and/or Matt (core devs) are always there and ready to help. http://webchat.freenode.net/?channels=podscmsIf you move it to your functions.php file in your theme you really shuoldn't have a problem with accessing any pods functionality.
hsatterwhite
Concated Scott via chat..and was able to find a solution to my original question.. needed to include require_once(realpath('../../../wp-load.php'));in the new php file
Sharath
That's awesome, glad you were able to find a solution :)
hsatterwhite
A: 

Correct, you'll want to use the following code to include WP into the page so you can utilize any of the php functions contained in the activated plugins (in this case, Pods):

require_once(realpath('../../../wp-load.php'));
Scott Kingsley Clark