MONKEYDEVIL API TOOLKIT

How to use the Monkeydevil API Toolkit

Toolkit installed and working? Here's how it works:

You or your client add some information to their CMS - let's say they've got a list of testimonials and they've added some entries to that. You want to display all of the testimonials on their website. In order to do this, you need to do two things:

  1. Retrieve all of the testimonials for the client
  2. Process and display the testimonial information on the website

Been there, done that?

click here to go straight to the module reference area.

Retrieving information from the CMS

We're not sure that this could be simpler! This is how you get all testimonials from the CMS (you can use this code with the demo account):

$api->executeOperation('site_getAllDepartmentTestimonials', 'Testimonials');
$arrResponse = $api->getAPIResponse();
$arrTestimonials = getKey('TESTIMONIALS', $arrResponse);

These lines of code should provide you with an array $arrTestimonials, containing all of the testimonials relating to the current client.

You can use print_r($arrTestimonials); to see the contents of the array. It should look something like this:

Array
(
    [0] => Array
        (
            [TESTIMONIALID] => XX
            [TESTIMONIALTEXT] => Andy and Ph...after time.
            [TESTIMONIALAUTHOR] => Stuart Marshall, Guitar Retreats
            [TESTIMONIALDATE] => 2009-10-30
            [TESTIMONIALUSERSNAME] => XXXXXX
            [TESTIMONIALLINKCOLLECTION] => Array
                (
                    [LINKCOLLECTIONID] => 0
                    [LINKCOLLECTIONTITLE] => 
                    [LINKCOLLECTIONDESCRIPTION] => 
                    [LINKCOLLECTIONITEMS] => 
                )
        )

    [1] => Array
        (
            [TESTIMONIALID] => XX
            [TESTIMONIALTEXT] => Immediately grasped...with Monkeydevil and are looking forward to... 
            [TESTIMONIALAUTHOR] => The Edgcumbe Team, The Edgcumbe Hotel
            [TESTIMONIALDATE] => 2009-11-04
            [TESTIMONIALUSERSNAME] => XXXXXX
            [TESTIMONIALLINKCOLLECTION] => Array
                (
                    [LINKCOLLECTIONID] => 0
                    [LINKCOLLECTIONTITLE] => 
                    [LINKCOLLECTIONDESCRIPTION] => 
                    [LINKCOLLECTIONITEMS] => 
                )
        )
)

Processing & Displaying Information on the Website

For those of you that are au fait with the PHP language, you can probably take it from here (or even from a few steps ago), but for the benefit of those who are just learning PHP, we'll introduce a few processes that you can go through to make life a little easier.

If after this you still don't understand then we've put together a few templates that you can simply drag, drop & customise to suit your client sites. Skip to the bottom of the page for a link to the module reference area if you think you're wasting your time trying to learn!

Using the above array of testimonials as an example, we'll write some PHP using foreach to loop through our array. You can find out more about the commands used by visiting www.php.net.

foreach($arrTestimonials as $testimonial)
{
    $testimonialText = getKey("TESTIMONIALTEXT", $testimonial);
    $author = getKey("TESTIMONIALAUTHOR", $testimonial);
    print "<div class='testimonial'>";
        print "<div class='testimonialtext'>";
            $testimonialText = "<p>&ldquo;". str_replace("\n", "</p><p>", $testimonialText) ."&rdquo;</p>";
            $testimonialText = str_replace("<p></p>", "", $testimonialText);
            print $testimonialText;
        print "</div>";
        print "<div class='testimonialbigauthor'>";
            print "<p>". $author ."</p>";
        print "</div>";
    print "</div>";
}

And that's it - there's obviously a lot more that you can do with the information you're provided - some testimonials might have links attached to them that you want to output, or you might want to add the date that the testimonial was added, but essentially it's that simple!

Module Reference

You're might now be interested in finding out about the different modules available and maybe having a play with them to see if they're suitable for you...

click here to see the API module reference.