-
- 25 Posts
I’m trying to set up a page with a random background image drawn from a tv in one of my "background" documents. Easy enough using Ditto and a simple tpl chunk. Elsewhere on the page, however, I’d like to be able to link to the page that includes the full image (used in the background) and a description of that photo. The trick for me is that I want the background image to be selected randomly from all of the available pages.
I can randomize the output for the background, but is it possible to store that value so that I can then link to the corresponding document later in the page?
Thanks for any suggestions.
-
- 25 Posts
here’s how I addressed this.
1. Call a custom snippet, get_rand_doc, that selects a document at random from those that have ’backgrounds’ as a parent. Set its ’id’ as a session variable.
2. Call Ditto. Using the ’documents’ parameter set to the session variable to return the background image.
3. Call Ditto again in the same way but with a different tpl chunk to return the link to the full page.
4. Call another custom snippet that unsets the session variable.
Seems kind of sloppy. If anyone has any other suggestions, I’d appreciate, but for now, it’s done.
Can’t you just use your random selection snippet as a parameter to the GetField snippet?
-
- 25 Posts
Much thanks for both suggestions. I will give each a try.