Skip to content

Instantly share code, notes, and snippets.

@thetrickster
Last active December 18, 2015 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thetrickster/5718742 to your computer and use it in GitHub Desktop.
Save thetrickster/5718742 to your computer and use it in GitHub Desktop.
Business Catalyst Multiple Random Web App Items - Add this code to your page where you want the random items to appear.
<!--
The element where your web app items will be appended to.
By default the script looks for an id of "random-web-app-items"
IMPORTANT: jQuery must be loaded on the page either in the HEAD of the doc or before you call the SCRIPTS below.
-->
<div id="random-web-app-items"></div>
<!-- Download this script to your site and replace the SRC with the path to your site's javascript file -->
<script src="//gist.github.com/thetrickster/5718857/raw/f0d736a4f80248c9c1a4184dcc43e223ac1e1d03/random-web-app-items.js"></script>
<script>
// Setup a javascript array to hold our web app item data
var webAppItems = [];
/*
This webapps module outputs all the web app items (up to 100) and uses a custom template which can be
found at: https://gist.github.com/thetrickster/5718819
Replace the attributes below with your webapp ID and the path to your site's custom module template.
*/
{module_webapps,13853,a,,,,,,100 template="random-webapp-layout.tpl"}
$(document).ready(function() {
// Function takes two arguments: target and num
// target: the element you are going to add the web app items to, it's usually an empty div..
// // default value: $("#random-web-app-items")
// num: the number of random web app items to insert into the target
// // default: 2
randomWebAppItems();
});
</script>
@thetrickster
Copy link
Author

Business Catalyst Multiple Random Web App Items

See the javascript/code needed to run randomWebAppItems(): https://gist.github.com/thetrickster/5718857
See the custom module template the module above renders: https://gist.github.com/thetrickster/5718819

HTML and Javascript for the destination page for your random web app items.

  • Replace SCRIPT references with your own versions of the downloaded files.
  • Also, be sure jQuery is loaded on the page before these scripts. If you have another jQuery ready function in your site's existing javascript you can remove the ready function below and add the randomWebAppItems() function to your existing ready function.
  • Replace parts of the module code below to represent your web app id and your template location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment