Skip to content

Instantly share code, notes, and snippets.

@whyisjake
Created December 7, 2011 03:37
Show Gist options
  • Save whyisjake/1441335 to your computer and use it in GitHub Desktop.
Save whyisjake/1441335 to your computer and use it in GitHub Desktop.
Featured Products
<?php
$input = range(1,30);
$arr = array_rand($input, 4);
error_reporting('E_All');
$request_url = 'http://makershed.com/net/webservice.aspx?api_name=generic\featured_products';
$xml = simplexml_load_file($request_url) or die('feed not loading');
$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>Featured Products from the <a href="http://makershed.com">MakerShed</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; ?>"><?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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment