-
- 61 Posts
I am sure I am being really stupid here but what the heck. I am using the RandomImage snippet and it is doing what it is required to do, but is there a way to tell it to display as a background image.
Thanks in advance for your help
-
- 9 Posts
I did similar thing. I needed to have random banner pictures.
So I created one folder with pages which contain HTML piece of code with (IMG markup). Every picture = one document.
And in the template you can use DITO snippet with the following parameters: parent=’ID of your folder’, display=1, randomize=1, total=all.
If you are setting backgroundimage in CSS style, you should use CSS style as a document in MODx using DITO snippet as well.
This could be used for any random requests without ad-hoc snippets - random jokes, random pictures, random quotations, etc.
HTH.
P.
I always thought using Ditto and the database like that was a bit of an overkill for something as simple as grabbing a random image from a given folder, though.
To use it for a background image, have the CSS that specifies the background image for a given element in a <style> block in your template head, and use the snippet there.