I wanted to use a random, rotating image as my site’s masthead and there was no simple way to do this in Textpattern. Initially I wrote a form with custom PHP code, including the Textpattern config, connecting to the database, doing a query… it seemed messy. So I started over and decided to do it as a plugin.
To install:
- Download the plugin file (see link below)
- Go to Textpattern’s admin tab
- Go to the plugins tab
- Paste the contents of the downloaded file into the text box and click upload.
- Once the plugin shows up in the list, you’ll have to click ‘no’ in the Active column to change it to ‘yes’; then the plugin will be active.
To use:
- Upload your masthead images using Textpattern’s image system. Put them all into the same category. I’ll use “site-masthead” as an example.
- Where you want the masthead to appear, add the tag
<txp:dml_rand_masthead category="site-masthead" />
By default, the link will be built so that the tool tip is “Go to main page”. You can change this to any value you want by adding the linktext attribute, e.g.: <txp:dml_rand_masthead category="site-masthead" linktext="Return to home page"/>
You can also give the class="classname" attribute to attach a CSS class to the masthead.
Download dml_rand_masthead-0.5.txt
Tags: textpattern