I need to add a random class from a selection of pre-defined classes to the body tag of a template.

I did it with JS but the change is visible so I would like to do it before the page is rendered.

Any ideas?

Many thanks Mikee

4 Answers 4


You could use Low Random maybe?

{exp:low_random:item items="cat|dog|ferret|raptor"}

  • Yup, that is ideal!
    – MikeeBee
    Commented Jul 3, 2013 at 10:52

Low Random looks like it'd do the job.


Inefficient I guess but you could use channel entries with a random sort order, a matrix field with the same or I think Low Variables would be the most efficient way.

  • Do you mean that Low Random will be inefficient or using channel entries?
    – MikeeBee
    Commented Jul 3, 2013 at 10:49
  • I meant using channel entries. Glad to see the answer - learned something new today : ) Commented Jul 3, 2013 at 10:57

People have mentioned low Random, but the Randomizer plugin can also be used to add strings to just about anything (images, text, whole paragraphs, a class...) It's lightweight, it's easy to use (though you have to edit the PHP file to build the arrays) and it will insert the content before the page is rendered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.