Skip to content

Instantly share code, notes, and snippets.

@whyisjake
Created December 12, 2011 22:34
Show Gist options
  • Save whyisjake/1469461 to your computer and use it in GitHub Desktop.
Save whyisjake/1469461 to your computer and use it in GitHub Desktop.
js_featured_products
function js_featured_products() {
$input = range(1,30);
$arr = array_rand($input, 4);
$request_url = 'http://makershed.com/net/webservice.aspx?api_name=generic\featured_products';
$xml = simplexml_load_file($request_url);
$products = $xml->Product;
?>
<style type="text/css">
.features { margin:20px 0 0; border:1px solid #eee; padding:10px; }
.features img { padding:5px; margin:0px; background-color: #eee; border:1px solid #ddd; }
.features h3, .features h4, .features h5, .features h6 { line-height: 24px; }
.clear { clear:both; }
.features .blurb { margin-left:0px; }
.features h3 { margin-bottom:12px; }
.features h4 { font-size:13px; line-height: 16px;}
.features .twenty-five { width:25%; float:left; text-align:center;}
.features .small-thumb { max-height: 75px; max-width: auto; }
</style>
<div class="row">
<div class="span10">
<div class="features">
<h3>In the <a href="http://makershed.com">Maker Shed</a></h3>
<div class="twenty-five">
<a href="http://www.makershed.com/SearchResults.asp?Search=<?php echo $products[$arr[0]]->ProductCode; ?>"><img src="<?php echo $products[$arr[0]]->PhotoURL; ?>" alt="<?php echo $products[$arr[0]]->ProductName; ?>" class="small-thumb"/></a>
<div class="clear"></div>
<div class="blurb">
<h4><a href="http://www.makershed.com/SearchResults.asp?Search=<?php echo $products[$arr[0]]->ProductCode; ?>&Click=37845"><?php echo $products[$arr[0]]->ProductName; ?></a></h4>
</div>
</div>
<div class="twenty-five">
<a href="http://www.makershed.com/SearchResults.asp?Search=<?php echo $products[$arr[1]]->ProductCode; ?>"><img src="<?php echo $products[$arr[1]]->PhotoURL; ?>" alt="<?php echo $products[$arr[1]]->ProductName; ?>" class="small-thumb"/></a>
<div class="clear"></div>
<div class="blurb">
<h4><a href="http://www.makershed.com/SearchResults.asp?Search=<?php echo $products[$arr[1]]->ProductCode; ?>"><?php echo $products[$arr[1]]->ProductName; ?></a></h4>
</div>
</div>
<div class="twenty-five">
<a href="http://www.makershed.com/SearchResults.asp?Search=<?php echo $products[$arr[2]]->ProductCode; ?>"><img src="<?php echo $products[$arr[2]]->PhotoURL; ?>" alt="<?php echo $products[$arr[2]]->ProductName; ?>" class="small-thumb"/></a>
<div class="clear"></div>
<div class="blurb">
<h4><a href="http://www.makershed.com/SearchResults.asp?Search=<?php echo $products[$arr[2]]->ProductCode; ?>"><?php echo $products[$arr[2]]->ProductName; ?></a></h4>
</div>
</div>
<div class="twenty-five">
<a href="http://www.makershed.com/SearchResults.asp?Search=<?php echo $products[$arr[3]]->ProductCode; ?>"><img src="<?php echo $products[$arr[3]]->PhotoURL; ?>" alt="<?php echo $products[$arr[3]]->ProductName; ?>" class="small-thumb"/></a>
<div class="clear"></div>
<div class="blurb">
<h4><a href="http://www.makershed.com/SearchResults.asp?Search=<?php echo $products[$arr[3]]->ProductCode; ?>"><?php echo $products[$arr[3]]->ProductName; ?></a></h4>
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<div class="clear"></div>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment