txp:dml_rand_masthead

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:

  1. Download the plugin file (see link below)
  2. Go to Textpattern’s admin tab
  3. Go to the plugins tab
  4. Paste the contents of the downloaded file into the text box and click upload.
  5. 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:

  1. Upload your masthead images using Textpattern’s image system. Put them all into the same category. I’ll use “site-masthead” as an example.
  2. 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:

Leave a comment