Last active
August 29, 2015 14:17
-
-
Save MikSDigital/f8c01340d7eb76b5b6d8 to your computer and use it in GitHub Desktop.
Widget as file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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