Skip to content

Instantly share code, notes, and snippets.

@tealdeal
Last active October 2, 2018 01:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tealdeal/b125d90507db888a9a52 to your computer and use it in GitHub Desktop.
Save tealdeal/b125d90507db888a9a52 to your computer and use it in GitHub Desktop.
elastic grid like google images: get content from instructables account (Javascript + PHP) to display your projects
<!-- you need to find and download elastic_grid
at http://demo.phapsu.com/jquery.elastic_grid/
so you have the scripts listed below in your directory -->
<!-- this goes in the head -->
<link rel="stylesheet" type="text/css" href="jquery.elastic_grid/css/elastic_grid.min.css" />
<!-- this goes in the body where you want to display the elastic grid -->
<div id="elastic_grid_demo"></div>
<!-- this goes towards the bottom of the document -->
<script src="jquery.elastic_grid/js/modernizr.custom.js"></script>
<script src="jquery.elastic_grid/js/classie.js"></script>
<script type="text/javascript" src="jquery.elastic_grid/js/elastic_grid.min.js"></script>
<script type="text/javascript">
$(function(){
$("#elastic_grid_demo").elastic_grid({
'showAllText' : 'All',
'items' :
[
<?php
$url = "http://www.instructables.com/member/YOURMEMBERNAME/rss.xml?show=instructable";
$feed = simplexml_load_file($url);
$n = 0;
$feed_array = array();
foreach($feed->channel->item as $item)
{
$n++;
if(strpos($item->imageThumb,"com"))
{
$imgins = $item->imageThumb;
}
else
{
$imgins = "http://www.instructables.com" . $item->imageThumb ."";
}
$tags = get_meta_tags($item->link);
$iTitle= $tags['twitter:title']; // ARTICLE TITLE
$iDes= $tags['description']; // DESCRIPTION FROM INSTRUCTABLES
$iImg0= $tags['twitter:image0']; // THE MAIN IMAGE
$iImg1= $tags['twitter:image1']; // NEXT ARTICLE IMAGE
$iImg2= $tags['twitter:image2']; // ANOTHER ARTICLE IMAGE
$iImg3= $tags['twitter:image3']; //ANOTHER ARTICLE IMAGE
print "
{
'title' : '" . $iTitle . "',
'description' : '" . $iDes . "',
'thumbnail' : ['" . $imgins . "', '" .$iImg1 . "', '" .$iImg2 . "', '" .$iImg3 . "'],
'large' : ['" . $iImg0 . "', '" .$iImg1 . "', '" .$iImg2 . "', '" .$iImg3 . "'],
'button_list' :
[
{ 'title':'View on Instructables', 'url' : '" . $item->link . "' },
{ 'title':'Download PDF', 'url':'" . $item->link . "?download=pdf'}
],
'tags' : ['instructables']
},
";
}
?>
]
});
});
</script>
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-1.10.2.min.js">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment