SiteVision Onlinehelp
Search

Getting a random article from an archive

Question: How to get a randomly selected article from an archive?
To get all articles of an archive, you need to use a NodeIterator to iterate the children of the archive. Since the articles/children aren't a sized collection (as a List or such) you can not use a random "index" and get that article right away.

There are of course many ways to implement the 'iterate and use randomly found' functionality, but a third-party developer has published an example (swedish only) External link, opens in new window..

Note! As always when you implement something using a NodeIterator - you must write your code so it properly handles different node count in different versions for different users. All articles can have different permissions and exist in different versions. For instance: an authenticated user might be able to access more articles than an anonymous user - and there might be more/less articles available in the editing/offline version than in the published/online version. A NodeIterator only delivers existing articles that current user has permission to read.

Last updated:

se-sto-ste-sv5-1.sitevision-cloud.net
18.216.123.120