SIMPLX Widgeteer
Creator: Lars Wallin (larscwallin)
About SIMPLX Widgeteer
Integrate and Mashup the easy way!
More and more data on the web, as well as on local systems, are available through descriptive formats as xml and json. Such formats can be used to display data from other systems, such as news updates etc.
Displaying, or rendering, information in a json feed takes parsing of the json data, extracting relevant data and inserting this data into some kind of template document. This is where the Widgeteer steps in and keeps it SIMPLX!
The Widgeteer takes a very pleasent Modxish way to accomplish this: chunkMatching.
Consider the following json string:
----------------------------------------------------------------------------------------------------------------------
{ "source":"modx", "result":[ {"id":"1","type":"document","pagetitle":"JSON Test","description":"Simple demo of json"}, {"id":"2","type":"document","pagetitle":"JSON Test 2","description":"Simple demo of json 2"}
] }
----------------------------------------------------------------------------------------------------------------------
This is a very simplified json representing two pages in ModX.
First of all, as soon as you spot the char "{" its the start of a new json object representation. Consequently "}" finishes an object.
The first object in the json string above only has two attributes: "source", "result". "source" has the value "modx". The "result" attribute though is followed by "[". This sign represents the start of an array of json objects, in this case ModX documents. Widgeteer calls the "result" attribute "dataSetRoot", in other words the element which holds the array of data we want to render.
Information
Released
October 28, 2014
Supported Database
MySQL, SQL Server
License
GPLv2
Supported Versions
2.0 - <2.3
Downloads
3,531
Instructions
Install using Package Management as usual.
This is what you end up with after the install:
- A new simplx widgeteer category (possibly/hopefully with substructures)
- Under Templates you will find one new template called Widgeteer examples which contains further info and samples.
- Under Chunks you find sample Chunks, all called widgeteer__ something. These are the templates and datasets.
- Under Snippets you find, of course, the simplx_widgeteer itself; you also find two preprocessor Snippets
- In your assets/ folder you will have a new snippets folder in which you will find the xml2json folder/files. This makes it possible to get xml from a Web Service and easily convert it to json.
Have fun :)
Lars
New in 0.8.5-pl1
SIMPLX Widgeteer 0.8.5
UPDATE 120117 10:04
Fixed a bug in the templateNSPlaceholder method thanks to Keith Baker :)
NEW FEAUTURES
If you use namespaced placeholders, you can now reference the first object in any list (array). This was not possible before. This is going to be even easier later on as you are going to be able to query for objects using regex etc.
UPDATE 120115 16:59
Changed so that the default chunkMatchingSelector is "", which is more likely to be the case.
UPDATE 120114 02:57
Updated the reset concept again as i had not considered the problem enough. Now the reference should be correctly set to the root of the traversal history stack for every new placeholder in the iteration.
UPDATE 120113 00:04
Found that i didn't reset the array iterator when going through namespaced placeholders. Fixed but untested.