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
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It only takes a minute to sign up.
Sign up to join this communityI 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
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.
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.