JSON output
Permalink Browser Info Environment
Hi
I was wondering if there was a way to modify the view of data display block to output entries as a json array?
i was hoping to use custom views on the blocks to utilise js or something like google maps etc that require data in json format.
Here for exmple is a way of using a page list custom view to use google maps with page attributes of lat/long
I was hoping for something similar. Output the data from advanced forms with data display and custom view it to create a map or something similar.
Any help would be greatly appreciated.
Adam
I was wondering if there was a way to modify the view of data display block to output entries as a json array?
i was hoping to use custom views on the blocks to utilise js or something like google maps etc that require data in json format.
Here for exmple is a way of using a page list custom view to use google maps with page attributes of lat/long
<?php defined('C5_EXECUTE') or die("Access Denied."); $th = Loader::helper('text'); ?> <?php $addresses = array(); foreach ($pages as $page): $title = $th->entities($page->getCollectionName()); $url = $nh->getLinkToCollection($page); $lat = $page->getAttribute('lat'); $long = $page->getAttribute('long'); if ($lat && $long) { $position = 'latLng: ['.$lat.', '.$long .']'; $addresses[] = '{'.$position .', data:'.json_encode($url). '}'; }
Viewing 15 lines of 39 lines. View entire code block.
I was hoping for something similar. Output the data from advanced forms with data display and custom view it to create a map or something similar.
Any help would be greatly appreciated.
Adam
Type: | Pre-Sale |
---|---|
Status: | New |