Please, raise your hand if you know anything about asp content rotator.
This is possibly the less known component available since the introduction of asp 3.0... and possibly the less used. In fact, the component could be used in different situation, and it is worth knowing a little bit about it.
The content rotator component creates an object used to display different contents every time a visitor views your page. Not that bad, isn't it? I've already published a post about random quotes... remember? We are actually talking about something very similar, but - someway - simpler.
The objectIn order to benefit from the use of the content rotator component, we have to create an asp object like:
Now we can access the object methods. In the content rotator object there are only two methods:
The second displays all the content in the text file.
How to access the content of the text fileIn order to get and display the content of our text file, we use a simple response.write:
The ChooseContent method will get a part of the text file content and show it.
In the above code, we assume our text file is example.txt.
What about the text file?Our text file (example.txt) can contain text, links, images... anything represented in HTML tags.
Let's see some examples. Our example.txt file could contain:
As you can see, you can put anything you like in the text file.
<a href="http://thewebthought.blogspot.com/">The Web Thought</a>
But what's the meaning of those #n? That is an optional number that represents the relative weight of the HTML content string. The content rotator component will display the content according to those parameters. In the above example, it will display the first, the second and the fourth lines 3/10 of the times; the third line 4/10 of the times. That will give you the option to decide how frequently a content is displayed.