What is a widget?

A widget is a tool that pulls content from one location and displays it in a compact form at another location. Widgets are not advertisements, they are a way to cross pollinate sites. They should be helpful and functional.

Search widget

The marketplace search widget is intended to be a tool to promote marketplace search on other sites. It consists of a header graphic, search box, and an optional featured business listing.

Quick example:

<script type="text/javascript">
  mp_search_widget = {
    'header_url': 'http://media.ljworld.com/static/marketplace_default/images/widgets/search_header.jpg',
    'marketplace_url': 'http://ljworld.com/marketplace/'
<script type="text/javascript" src="http://media.ljworld.com/static/marketplace_default/javascript/search_widget.js"></script>
<script type="text/javascript" src="http://ljworld.com/marketplace/api/v0/random_business_json/?callback=randomBusiness"></script>



Required parameters

In order for the widget to work you’ll need to provide it with some information about your marketplace site.

This needs to be a graphic (JPG or GIF) sized properly to fit the width of the widget. The default widget content area width is 280 pixels.
This needs to be a url to your marketplace site with the http:// prefix and ending forward slash.

Optional parameters

You can pass the search widget a few options to customize the look and size so it works with your site layout.

This sets the container width of the widget.
Sets the border around the widget container. Possible value would be 1px solid #dddddd which stands for the size, type and color.
Sets the ID of the widget tag so it can be exclusively targeted with CSS.

Data URL

If your Marketplace site is at http://example.com, the default data url is http://example.com/marketplace/api/v0/random_business_json/. This will query businesses in your default market. If you would like to create a widget that pulls from markets other than your default, append that market to data_url. For example: http://example.com/marketplace/api/v0/random_business_json/market/?callback=randomBusiness. The data url must have the callback parameter set to randomBusiness.

It is possible to further customize the widget by specifying options in your data_url. The following paramters can be passed to data_url as QueryString parameters:

The number of businesses to return (default: a list of one business).
Limit businesses returned by category path (default: None).
Crop business photo to this width (default: 80).
Crop business photo to this height (default: 70).
Limit what type of businesses to return (allowed values: basic, expanded, homepage-sponsor, category-sponsor, None. Default: None [any business]).
Must be set to randomBusiness.

Here is an example of a data_url that businesses with custom photo sizes and a custom callback:


A call to data_url will return information used by the widget. If you would like to make use of the data_url within your own applications, here is an example of the data returned by the example above:

         "address1":"2540 Iowa St Ste M",
         "name":"Sunkissed Tanning",
         "hours_text":"Open today until 8:30 p.m.",
         "notes":"Kathy & Mike Byrnes (Owners)\r\nkathy@sunkissedlawrence.com\r\n816-665-4849 (Evening)",

The data_url returns a representation of each field stored for the business as well as a few extra fields:

A thumbnail of either the main photo for the business or the still for the main video.
The description of the business with any HTML tags removed.
A text description of if the business is open or if closed when it will be open next.




You are here:

This Page