-
- 56 Posts
I don’t know if this possible and more importantly how to make it happen. I’ve a test site for my Division’s website at www.prwiki.org. When you refresh the page you will see that the image and quote change randomly. However the quote is not connected to the image while ideally it should. Does anyone have an idea how I can randomy display an image with accompanying quotes which as you may have seen on the site are displayed in different divs (I use CSS positioning, even though I’m not very conversant with it..)
Thanks
-
- 1,732 Posts
Hmmm,
One eway to do this is to create a folder and in that folder create documents that would contain images and text. Then create a snippet or a TV (using @EVAL) to randomly display the content of documents inside the folder.
The other way is to wait until the Content Rotator TV control is released. No timelines on it’s release as yet
-
- 56 Posts
The problem is that this display of content would be in different areas, so split in two, the image in the top area and the quote in the below area which is defined by a different div. I don’t think that the "future" content Rotator TV control could do this either. Maybe I’m just asking for the "impossible"
-
- 372 Posts
Hey guys, I was looking for a way to just randomise text and found this post.
Thought I’d share my solution although it wont help Eko40 since it doesn’t deal with images, it might help someother newbie like me who is searching these posts.
The original Snippet is from Syn and I just modified it. See more at
http://www.etomite.org/forums/index.php?showtopic=1396&st=0&p=18668&#entry18668
$quote[] = "Text 1";
$quote[] = "Text 2";
$quote[] = "Text 3";
$quote[] = "Text 4";
if(!isset($id)) {
$id = $modx->documentIdentifier;
}
if ($id == '1') {
return "Text for Page 1";
}
else
if ($id == '6'){
return "Text for Page 6";
}
else {
$randomquote = rand(1, count($quote));
return $quote[$randomquote];
}
I then call it with [!SnipetName!] so it doesn’t cache the 1st result, which stops it being random
Briggsy
-
- 372 Posts
oops good point.... forgot
I changed the code on Etomite site as I only altered the orginal etomite code in the first place. Does Etomite use [!snippet!] or simillar to call a non cached version?
Thanks for the reminder, forgot they aren’t all as lucky as we are
Briggsy
Etomite does use the [! syntax as well.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me