Wednesday, January 18, 2012

ATG Slots



A slot is a type of component that you can create to hold items. When creating a slot, you specify certain attributes about the slot and the type of item you can put in the slot. A slot can contain only one type of item—for example, Products or Promotions, but not both. Slots must contain repository items; however, that item could be a media-external item that links to anything.

For information about how to create slots, refer to the ATG Personalization Programming Guide.

Slots are typically used in the following way: One or more scenario processes puts items into the slot, and another process looks in the slot and either displays the item in the slot or performs some other action on it.

The Pioneer Cycling site has several scenarios that populate slots with items. Then, various pages (including store_home.jsp and many catalog display pages) dynamically display pages based on the contents of these slots.

We used slots on the home page and among top-level pages. Slots can be filled with content, lists of products, or promotions.

Creating a Slot

Before you can populate a slot, you must first create it. A slot is a named component so it needs a .properties file. The slots properties files must reside in specific slot directories. The Pioneer Cycling store site has three different types of slots, so we created separate named components:

atg/repository/Slots/MediaSlot for media items

atg/repository/Slots/ProductSlot for Product items

Here is an example of the MediaSlot.properties file:

#/atg/registry/Slots/MediaSlot
$class=atg.scenario.targeting.RepositoryItemSlot
$scope=session
generation=0
itemDescriptorName=media-external
maxRenderSize=1
repositoryName=ProductCatalog
retrieval=1

As mentioned before, a slot can contain only one type of item. The itemDescriptorName defines what item type is put into this slot in this case media-external. The media-external type is defined in the ProductCatalog, so ProductCatalog is stored in the repositoryName attribute. The maxRenderSize indicates the maximum number of items that can be pulled out of the slot at one time. See the Using Slots chapter in the ATG Personalization Programming Guide for specifics on slots properties files.

We needed to create two slots for displaying promotions to our French and Japanese users: ProductSlotFr and ProductSlotJa. These are similar to the original product slot, except that they refer to the different repositories for the different language catalogs because each slot can only receive items from a single repository.

The MediaSlot was localized in a different fashion. The same slot is displayed to all three languages, but the media item that is placed into the slot checks the current locale, and renders the media in the appropriate language.

Populating a Slot

We created some scenarios that populate the Pioneer Cycling site’s MediaSlot with zero or more image files that contain promotional images we want to display at the top of store_home.jsp.

ATG Relationship Management Platform is very flexible and allows many options. We chose to create a scenario called “New Customers” that populates the Pioneer Cycling site’s MediaSlot with an HTML file containing an image that tells users they are eligible for 20% off their first purchase.

It accomplishes this with the “Show items in slot” action.

Displaying Items in a Slot

Once a slot is populated, you can do several things with the item in the slot. This section shows a simple slot item example.

store_home.jsp simply displays whatever image is in the media-external item (an HTML file with a reference to an image file) in the MediaSlot. The image is not clickable — the user just sees the image, but clicking on the image does not result in any special behavior.

store_home.jsp displays the contents of the MediaSlot using the DisplayMediaSlot.jsp fragment.

The following JSP fragment is used to display the contents of the MediaSlot:

<DECLAREPARAM NAME="NumToDisplay"
              CLASS="java.lang.String"
              DESCRIPTION="NumToDisplay">


<dsp:droplet name="/atg/targeting/TargetingFirst">
  <dsp:param name="howMany" param="NumToDisplay"/>
  <dsp:param bean="/atg/registry/Slots/MediaSlot" name="targeter"/>
  <dsp:param name="fireContentEvent" value="false"/>
  <dsp:param name="fireContentTypeEvent" value="false"/>
  <dsp:oparam name="output">
    <dsp:getvalueof id="media_url" param="element.url" idtype="String">
    <dsp:include page="<%=media_url%>" flush="true"/>
    </dsp:getvalueof>
  </dsp:oparam>
  <dsp:oparam name="empty">
    No special offers today!
  </dsp:oparam>


</dsp:droplet>

This fragment displays the first item in the MediaSlot. Because the items in the slot are of type media-external, they have a “url” property that can be used to display the media item. In this case, the “url” value in the repository item points to the name of a file that contains the desired image.

In addition to MediaSlot, the Pioneer Cycling site uses the ProductSlot to display various products to customers. Scenarios are created to populate the ProductSlot with products. Site developers can create scenarios to populate a ProductSlot with some of the site’s newest, coolest products.

You could also create a scenario to populate a ProductSlot with products that are overstocked and are being discounted to reduce stock. The Pioneeer Cycling site populates the ProductSlot with two simple scenarios. One is the “Show Products” scenario that adds the new QW-33 Bike and some related products to the ProductSlot. If the user views that particular bike, several other related parts are added to the ProductSlot via the “Cross Sell” scenario.

The ProductSlot display code is similar to the MediaSLot code. You can view the JSP at

<ATG9dir>/PioneerCyclingJSP/j2ee-apps/pioneer/
web-app/en/common/DisplayProductSLotHome.jsp.

No comments:

Popular Posts