Link:http://output.to/sideway/default.asp?qno=130200007 ASP Server Component, Pre-made Function, Content Rotator component ASP Server ComponentsSome of the ASP server components are the common features found in dynamic web pages. These base ASP server components are provided to enrich the pre-made functions of ASP technology for making dynamic and interactive web pages. However, some IIS pre-made components are not installed for all version of IIS. Ad Rotator, Browser Capabilities, Content Linker, Content Rotator, Counters, Logging Utility, My Info, Page Counter, Status, and tools are not installed with IIS 6.0. However, if you upgrade your Web server from a previous version of IIS, the pre-made components are not removed. Some IIS pre-made components, ASP content rotator and nextlink, are deprecated in IIS7. And most IIS pre-made components are either not installed with IIS7 or their usage is not supported. Content Rotator componentThe Content Rotator component can be used to create a ContentRotator object that acts as a HTML tags holder on an ASP page for controlling the rotation of HTML content strings to be displayed on a web page automatically. The function of the ContentRotator object is to automate the displaying of HTML content strings on the web page each time when an user opens or reloads the web page. A text file called Content Schedule File is used to store the information for controlling the way of the HTML content strings to be displaced on the web page. Since the HTML content strings can be texts or HTML tags, any type of content can be displayed by the ContentRotator object through HTML tags, e.g. text, images, or hyperlinks, even style control. Therefore a ContentRotator object can be used to rotate the content of a web page through a list of content items, hyperlinks, or style properties each time when the web page is opened or reloaded by the user. In addition to the Content Schedule file, the Content Rotator Component uses a random generator to select which of the weighted content strings is displayed, therefore a HTML content string may be repeated especially when there is only a few entries in the Content Schedule file, or one of the entries in the Content Schedule file is weighted much higher than the others. File NameThe file name of the Content Rotator component is Controt.dll. SyntaxSet ContRotName = Server.CreateObject( "MSWC.ContentRotator" ) ParametersContRotName The parameter "ContRotName" is the name assigned to the instance of the ContentRotator object created by the call using the Server.CreateObject. RemarkThe Content Rotator component does not work with Internet Information Server 7 (IIS7). ContRot.ChooseContent MethodContRot.ChooseContent method is used to retrieve the HTML content string from the Content Linking List file and response the HTML content string on the current ASP page. The script "ContRot.ChooseContent" runs each time when a user opens or reload the page, and the ContRot.ChooseContent method will retrieve a new random scheduled HTML content string each time. SyntaxContRotName.ChooseContent( content-schedule-path ) ParametersContRotName The parameter "ContRotName" is the name of the instance of the ContentRotator object to be set. content-schedule-path The parameter "content-schedule-path" is used to specify the location of the Content Schedule file. The path parameter can be specified by either using a relative or virtual path. The ContentRotator object will call the Server.MapPath method to map the specified path to the physical directory of the Content Schedule file. Return ValuesThe ContRot.ChooseContent method returns an HTML content string from the Content Schedule file. ContRot.GetAllContent MethodContRot.GetAllContent method is used to retrieve all of the HTML content strings from the Content Linking List file and response all HTML content strings on the current ASP page as a list with an <HR> tag after each entry. The script "ContRot.GetAllContent" is usually used to proofread all the HTML content strings in the Content Schedule file. SyntaxContRotName.ChooseGetAllContent( content-schedule-path ) ParametersContRotName The parameter "ContRotName" is the name of the instance of the ContentRotator object to be set. content-schedule-path The parameter "content-schedule-path" is used to specify the location of the Content Schedule file. The path parameter can be specified by either using a relative or virtual path. The ContentRotator object will call the Server.MapPath method to map the specified path to the physical directory of the Content Schedule file. Return ValuesThe ContRot.ChooseContent method returns all HTML content strings from the Content Schedule file and a HTML tag <HR> is added between two entries before strings are responsed to the ASP web page. Content Schedule FileThe Content Schedule File is used to store the specification details of the display schedule and scheduled entries of HTML content string in a collection for the Content Rotator component. There can be any number of HTML content string entries in the file. Each entry is divided into two parts. The first part is lines that begins with double percentage sings (%%) and is used for specifying the optional parameters, relative weight and comments. The second part is the HTML content string. Each line ends in a carriage return. The Content Linking List File should be stored under the web server directory so that the Content Linking List File can be accessed through a virtual path. For the optional parameters in the first part, a hash (#) character at the beginning of wording is used as the indicator of an weighting item while double slash (//) characters at the beginning of wording is used as the indicator of an comments item. The change in a Content Linking List File may need to restart the IIS services in ordered to make the changes become effective. Syntax
((%% [#Weight] [//comments])+ Parameters[...] The parameter "[" & "]" is the indicator of the bracketed parameters by a pair of square brackets "[...]" is an optional item unless other specified. (...)+ The parameter "+" is the indicator of the bracketed property parameters by a pair of brackets "(...)" can be repeated one or more times. Weight The optional parameter "Weight" is used to specify the individual relative weight of the HTML content string entry. Although a number between 0 and 10000 can be used for indicating the individual relative weight of the banner image, there is a limitation that the sum of the Weights for all entries cannot exceed 10000, otherwise an error will be generated when the Content Schedule file is called by the GetAllContent or ChooseContent method. The number 10000 is only the maximum total number of Weights for all entries in the collection. The weighting mechanism for the probability of display is expressed as the ratio of the individual weight of an item over the total number of Weights for all items in the Content Schedule file. For example, if a Content Schedule file contains three entries with weights set to 1, 3, and 4, the first content is displayed 12.5 percent of the time, the second 37.5 percent of the time, and the third 50 percent of the time. if the Weight is not specified, a default value 1 is assigned to the content. But a Weight of 0 will cause the entry of the content to be ignored by the ContentRotator object. comments The optional parameter "comment" is used to specify the comments about the content entry. The comment is for reference only and will not be displayed to the user. Multi-line comment is supported by repeating a line begins with the double percentage sings (%%) line delimiter and followed by the double slash (//) of a comment indicator ContentString The parameter "ContentString" is used to specify the HTML content string to be displayed by ContentRotator object. The HTML content string can be used to present text, image, or hyperlink, ...etc. Multi-line ContentString is supported. More than one lines of HTML content string can be entered because the ContentRotator object treats all lines between two line blocks with double percent signs (%%) as one single HTML content string entry. Examples
|
Sideway BICK Blog 13/02 |