Skip to content

Instantly share code, notes, and snippets.

@MikSDigital
Last active August 29, 2015 14:17
Show Gist options
  • Save MikSDigital/f8c01340d7eb76b5b6d8 to your computer and use it in GitHub Desktop.
Save MikSDigital/f8c01340d7eb76b5b6d8 to your computer and use it in GitHub Desktop.
Widget as file
jQuery(function($){
$.ajax({
type: 'GET',
url: 'http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?',
data: {
tags: "cats",
//tagmode: "any",
format: "json",
//sort: "random"
},
dataType: 'jsonp',
crossDomain: true,
}).done(function(data){
console.log(data);
$.each(data.items, function(i,item){
$("<img/>")
.attr("src", item.media.m)
.appendTo(".cube")
.wrap("<a target='_blank' href='" + item.link + "'>");
if ( i == 5 ) return false;
});
}).fail(function(error){
console.log(error.statusText);
});
});
<?php
$modx->regClientCSS('widgets/cube/magic.css');
$modx->regClientStartupScript('//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js');
$modx->regClientStartupScript('widgets/cube/getjson.js');
$tpl = <<<EOT
<div class="space">
<div class="cube"></div>
</div>
EOT;
$chunk = $modx->newObject('modChunk');
$chunk->setContent($tpl);
$chunk->setCacheable(false);
$output = $chunk->process();
return $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment