1

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

You could use Low Random maybe?

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

1
  • Yup, that is ideal! – MikeeBee Jul 3 '13 at 10:52
3

Low Random looks like it'd do the job.

0
0

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.

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

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, privacy policy and cookie policy

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