12.2 Content Rotator

The Content Rotator component automates the rotation of the specified content on a Web page. Each time you open or reload a Web page, new content based on the information specified in the Content Rotator Schedule file is displayed. One common application of this component is the Thought for the Day section on a Web page. Whenever you access a Web page, a different 'Thought' appears.

12.2.1 Content Rotator Schedule File

The ContentRotator Schedule file contains information used by the Content Rotator component for managing and displaying the specified content. In this file you can include several content strings.

Each entry consists of two sections:

  • The first part comprising of a line that begins with two percentage symbols (%%) and contains both the relative weight and comments.
  • The second part that contains the HTML content itself.

Syntax

The syntax of the ContentRotator Schedule file is:

 %% [#Weight] [//Comments]
 ContentString
 

Parameters

Weight
Optional. Specifies an integer (0 - 10000) representing the relative weight of the content string. If it is 0, the content entry string will be ignored.The probability of display for a particular content string can be expressed as the Weight of that content string divided by the sum of Weight values for all entries in the Content Schedule file.

For example, if a Content Rotator Schedule file contains three content strings with weights set to 4, 7, and 9, the first string has a probability of 20 percent, the second has 35 percent, and the third has 45 percent. By default the weight will be set to 1.

NOTE:If the sum of all weight values exceeds 10000, an error will be generated when the schedule file is accessed by a call to either the GetAllContent or ChooseContent methods.

Comments
Optional. Contains comments about the entry. These comments are for development use only and are not displayed to the user. If multiple comments are given, each additional comment line should start with a line delimiter (%%) followed by a comment delimiter (//).
ContentString
The content that the Content Rotator object displays. This can spread over one or more lines. The Content Rotator object treats everything between blocks of double percentage symbol (%%) as a single content string. The content can include HTML tags since the output is directed to a browser.

Example

The following is a sample Content Rotator Schedule file to display a variety of content.

 CONTROT.TXT
 %% #2 // The weight is 5.
 Everything is connected.
 
 %% #2 // Content can be more than one line long
 %% // Note that HTML tags are used in this content
 
 <FONT FACE="ARIAL,HELVETICA" SIZE="2">
    Look before you
    <H1>leap</H1>.
 </FONT>
 %% #5
 Smile like
 <Font Face ="Terbuchet,Tahoma" Size="4">
  <a href=images/smile.gif>me</a>
 </Font>
 
 

12.2.2 Object Diagram

Describes  the hierarchy of various objects in the Content Rotator component

12.2.3 Content Rotator Object

Automates the rotation of content on a Web page.

12.2.4 ChooseContent method

Gets the content string from the Content Rotator Schedule file and displays it on the Web page.

Syntax

 object.ChooseContent(
   ContentScheduleFilePath As String)
 

Parameters

ContentScheduleFilePath
Relative or absolute path of the Content Rotator Schedule file.

Return Values

String. This is a set of HTML tags required by the browser to display the next content.

Remarks

The content is chosen randomly. The probability is defined by the Weight value specified in the Content Rotator Schedule file. See Syntax for details.

Example

This example displays the Thought for the Day.

 	<% ’Displays Thought for the Day.
 	Set Thought = CreateObject("MSWC.ContentRotator") %>
 		<% =Thought.ChooseContent("controt.txt") %>
 

12.2.5 GetAllContent method

Gets all the content strings from the Content Rotator Schedule File and displays them on the Web page as a list with horizontal rule (<HR>) as separator.

Syntax

 object.GetAllContent(
   ContentScheduleFilePath As String)
 

Parameters

ContentScheduleFilePath
Relative or absolute path of the Content Rotator Schedule file.

Return Values

Null.

Example

This example displays all content of the Thought For The Day file

 <% ’Displays all content of the Thought For The Day file.
 	Set Thought = CreateObject("MSWC.ContentRotator")
 	Thought.GetAllContent("controt.txt") %>