{"id":2005,"date":"2009-10-10T09:43:23","date_gmt":"2009-10-10T08:43:23","guid":{"rendered":"http:\/\/www.bitvolution.com\/?p=34"},"modified":"2016-12-04T09:59:28","modified_gmt":"2016-12-04T09:59:28","slug":"show-more-than-10-items-in-a-amazon-carousel","status":"publish","type":"post","link":"https:\/\/www.tomfotherby.com\/blog\/index.php\/2009\/10\/show-more-than-10-items-in-a-amazon-carousel\/","title":{"rendered":"Show more than 10 items in a Amazon Carousel"},"content":{"rendered":"<p><em>What is a &#8220;Amazon Carousel&#8221;<\/em>? It is a advert showing a bunch of items you can buy on Amazon:<\/p>\n<div style=\"text-align:center\">\n<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"https:\/\/fpdownload.macromedia.com\/get\/flashplayer\/current\/swflash.cab\" id=\"Player_f128ff48-1809-467c-be6c-1daf7ca506e5\"  width=\"400px\" height=\"150px\"><param name=\"movie\" value=\"https:\/\/ws.amazon.co.uk\/widgets\/q?ServiceVersion=20070822&#038;MarketPlace=GB&#038;ID=V20070822%2FGB%2Ftomfotsblo-21%2F8010%2Ff128ff48-1809-467c-be6c-1daf7ca506e5&#038;Operation=GetDisplayTemplate\" \/><param name=\"quality\" value=\"high\" \/><param NAME=\"bgcolor\" value=\"#FFFFFF\" \/><param name=\"allowscriptaccess\" value=\"always\" \/><\/object> <noscript><a href=\"https:\/\/ws.amazon.co.uk\/widgets\/q?ServiceVersion=20070822&#038;MarketPlace=GB&#038;ID=V20070822%2FGB%2Ftomfotsblo-21%2F8010%2Ff128ff48-1809-467c-be6c-1daf7ca506e5&#038;Operation=NoScript\">Amazon.co.uk Widgets<\/a><\/noscript>\n<\/div>\n<p>\nAmazon put a limit on the number of items in a carousel. However, if you have more than 10 items, you can use a little javascript to select 10 at random so a different set are shown on each page view.\n<\/p>\n<p>This is some javascript that randomises an array of ASIN numbers:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar asinArray = new Array('0874477182', '0764138057', '0764136321', '0375428569', '0375764313', '037576433X', '0375428607', '141955252X', '141955039X', '0874477565', '0874477727', '037576593X', '0375429115', '0375765891', '0375765883', '0375429093', '0375429077', '0375429123', '0375429085', '0953265978', '0856609781', '1402209592', '0375428720', '0312366914', '0142003085', '0374525137', '0143112821', '0099479028', '1932080309', '0140620184', '0141185570', '014023750X', '014103534X', '0312361785');\r\ndocument.write('Normal : ' + asinArray + '&lt;br \/&gt;');\r\nasinArray.sort(function(){return (Math.round(Math.random())-0.5); });\r\ndocument.write('Random : ' + asinArray + '&lt;br \/&gt;');\r\n<\/pre>\n<p>To select 10 from the randomised array:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nif (asinArray.length &gt; 10)\r\n asinArray.length = 10;\r\ndocument.write('Random 10: \\'' + asinArray.join(',') + '\\'&lt;br \/&gt;');\r\n<\/pre>\n<p>To apply this to the Amazon Carousel:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;script type='text\/javascript'&gt;\r\nvar asinArray = new Array('0874477182', '0764138057', '0764136321', '0375428569', '0375764313', '037576433X', '0375428607', '141955252X', '141955039X', '0874477565', '0874477727', '037576593X', '0375429115', '0375765891', '0375765883', '0375429093', '0375429077', '0375429123', '0375429085', '0953265978', '0856609781', '1402209592', '0375428720', '0312366914', '0142003085', '0374525137', '0143112821', '0099479028', '1932080309', '0140620184', '0141185570', '014023750X', '014103534X', '0312361785');\r\nasinArray.sort(function(){return (Math.round(Math.random())-0.5); });\r\nif (asinArray.length &gt; 10)\r\n\tasinArray.length = 10;\r\nvar asinText = &quot;'&quot;+asinArray.join(',')+&quot;'&quot;;\r\nvar amzn_wdgt={widget:'Carousel'};\r\namzn_wdgt.tag='&lt;your Amazon id&gt;';\r\namzn_wdgt.widgetType='ASINList';\r\namzn_wdgt.ASIN=asinText;\r\namzn_wdgt.title='New Video Game titles from Amazon';\r\namzn_wdgt.width='600';\r\namzn_wdgt.height='200';\r\namzn_wdgt.marketPlace='GB';\r\n&lt;\/script&gt;\r\n&lt;script type='text\/javascript' src='http:\/\/wms.assoc-amazon.co.uk\/20070822\/GB\/js\/swfobject_1_5.js'&gt;\r\n&lt;\/script&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>What is a &#8220;Amazon Carousel&#8221;? It is a advert showing a bunch of items you can buy on Amazon: Amazon.co.uk Widgets Amazon put a limit on the number of items in a carousel. However, if you have more than 10 items, you can use a little javascript to select 10 at random so a different [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[82],"tags":[80,81],"class_list":["post-2005","post","type-post","status-publish","format-standard","hentry","category-web-design","tag-amazon","tag-javascript"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.tomfotherby.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tomfotherby.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tomfotherby.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tomfotherby.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tomfotherby.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=2005"}],"version-history":[{"count":2,"href":"https:\/\/www.tomfotherby.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2005\/revisions"}],"predecessor-version":[{"id":2051,"href":"https:\/\/www.tomfotherby.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2005\/revisions\/2051"}],"wp:attachment":[{"href":"https:\/\/www.tomfotherby.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=2005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tomfotherby.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=2005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tomfotherby.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=2005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}