Skip to main content

Documentation

What is this?

This package defines several browser views that do a redirect to random content.

Use case

The main use case would be: a random header background image. Use @@randomimage as background image in a css file. When the browser loads the css file and wants to apply the background image, it will get redirected to the image.

Example css code for when you want a random background image on all pages except the front page, is this:

#portal-header {
  background: url(@@randomimage) no-repeat 0 0;
}
.section-front-page #portal-header {
  background: #ee0;
}

Alternative

collective.randomheaderimage achieves the same thing as using @@randomimage in a css file. It does this by overriding the plone.header viewlet and adding some inline css to it. This works fine. It has one possible drawback: if you use caching, then you always get the same image for a page, until the cache gets refreshed. This may or may not be a problem for you.

Installation and configuration

Add collective.randomcontent to the eggs of your buildout (zcml is not explicitly needed), rerun buildout and start your zope instance.

Install collective.randomcontent in the Site Setup. Go to its control panel and choose a folder in your site where we take images from.

Note that when you only want to use @@randomsiteimage or @@randomsitecontent, you do not need to install this package in the site setup.

Details

The following views are available:

  • @@randomimage: this picks a random image from your site and redirects to this url. The image must be in a specific folder, that you set in the control panel.

  • @@randomsiteimage: this picks a random image from your site and redirects to this url. The image can be anywhere in your site.

  • @@randomcontent: this picks a random content item from your site and redirects to this url. The content must be in a specific folder, that you set in the control panel.

  • @@randomsitecontent: this picks a random content item from your site and redirects to this url. The content can be anywhere in your site.

Compatibility

This is tested on Plone 4.2. It will likely work on all 4.x versions.

It might work on Plone 3, but it uses plone.app.registry, which is not available by default, so you may need to take extra care about getting versions of packages that work for your Plone version. This is untested.

Authors

  • Maurits van Rees

Changelog

1.0 (2012-07-19)

  • Initial release [maurits]

Release files for collective.randomcontent 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for collective.randomcontent 1.0
File Size Uploaded
collective.randomcontent-1.0.zip 31.7 kB Details

Release files / collective.randomcontent-1.0.zip

Download URL collective.randomcontent-1.0.zip
Size 31.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6643bda2742599bc64ab28c224a7a15401411d5b3e5925168516cd02733aed6c
BLAKE2b-256 checksum
How to use checksums
45c5e707bf811ec148bce47e89a3930eea7f49681f28017d3f3477f81cff98a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page