JSON and SOAP Parsing Plugins for Smarty

Smarty plugins for parsing JSON

This is a simple plugin for Smarty to retrieve and parse JSON data. Requires the PECL JSON.php class or PHP 5.2.0.

Instructions:

  1. (if your PHP version is < 5.2.0) and save it to your include path if it is not already there. If your php version is >= 5.2.0, this class is not needed, we will use the native function.
  2. Download the JSON Smarty Plugin PHP Function File as function.json.php in your smarty\plugins\ directory.

Usage in Smarty templates:

{json url=http://site.com/data.json resource=result}

The $result variable now contains the parsed JSON data! Enjoy!

Smarty plugins for parsing SOAP

This plugin for Smarty enables in-template access to SOAP services.

It requires the NuSOAP php class in your PHP include folder (ie: includes_path/nusoap/nusoap.php) or edit the path in the soap smarty plugin.

You may need to download the NuSOAP php class and place it in your PHP include path.

The smarty soap plugin function is here.

Usage in Smarty Templates:

        {soap assign=soapResponse
        endpoint=http://site.com/resource.soap
        call=resource..search
        var=(string)Test
        debug=true|false}