I'm developing a site where it would be helpful to have some random blocks of text in a sidebar. I'm not talking about random quotes of a few words, but maybe 200 words. The idea is for some basic "refresher info" to show up along side certain topics.
(Using different templates is not an option.)
The random quotes tag from CMS Made Simple, and others I have seen, all assume only a line of text. Does anyone know of a method I could use?
TIA Andrew Prior
[SOLVED!] Random blocks of text
-
- Forum Members
- Posts: 247
- Joined: Sun Oct 28, 2007 4:14 am
[SOLVED!] Random blocks of text
Last edited by Anonymous on Tue Jul 29, 2008 12:26 am, edited 1 time in total.
-
- Forum Members
- Posts: 247
- Joined: Sun Oct 28, 2007 4:14 am
Re: Random blocks of text
I guess a Global Content block would do the trick as a "container" for text, as it will take formatting. So if I could randomise the global content block which appeared... 

-
- Forum Members
- Posts: 247
- Joined: Sun Oct 28, 2007 4:14 am
Re: Random blocks of text
I think I've fixed this issue for myself. I guess a programmer would do it in 2 minutes
, but I'm a writer, so it's a different story!
I've only tested in IE 7 at this stage, so I may have surprises.
I imagine that some kind if if else statement could make it a lot tidier, too.
Step one, take Calguy's capture randomiser for images and make it a global content statement as per below
{capture assign='num'}{1|rand:3}{/capture} {* generate a random number between 1 and 3, assign it to 'num *}
I've called this 'rand0ne'
Step Two: Make up your three global content blocks. I've called them blob1 blob2 and blob3
Step Three: Then in the template where the random text is to appear use the following code:
Then I get the appropriate content showing up and matching the $num variable.
Why do this? Well, the random quote tag doesn't take formatting or line breaks. So in my case it's not suitable. In this case I get some "random" text blocks which I will essentially use like a magazine call out in the side bar of a page. They can have formatting and links. So we will have ongoing discussions on a topic, and for newcomers there will be a random dispaly of some of the foundational articles and boundaries of the discussion in a condensed form. A person can follow the links to the full article.
Andrew

I've only tested in IE 7 at this stage, so I may have surprises.
I imagine that some kind if if else statement could make it a lot tidier, too.
Step one, take Calguy's capture randomiser for images and make it a global content statement as per below
{capture assign='num'}{1|rand:3}{/capture} {* generate a random number between 1 and 3, assign it to 'num *}
I've called this 'rand0ne'
Step Two: Make up your three global content blocks. I've called them blob1 blob2 and blob3
Step Three: Then in the template where the random text is to appear use the following code:
Code: Select all
{global_content name='rand0ne'}
{$num} {* this is just showing me that the random capture is working while I'm testing. *}
{if $num == 3 }
{global_content name = 'blob3'}
{/if}
{if $num == 2 }
{global_content name = 'blob2'}
{/if}
{if $num == 1 }
{global_content name = 'blob1'}
{/if}
Why do this? Well, the random quote tag doesn't take formatting or line breaks. So in my case it's not suitable. In this case I get some "random" text blocks which I will essentially use like a magazine call out in the side bar of a page. They can have formatting and links. So we will have ongoing discussions on a topic, and for newcomers there will be a random dispaly of some of the foundational articles and boundaries of the discussion in a condensed form. A person can follow the links to the full article.
Andrew
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: [SOLVED!] Random blocks of text
{capture assign='num'}{1|rand:3}{/capture}
{capture assign='blobname'}blob{$num}{/capture}
{global_content name=$blobname}
{capture assign='blobname'}blob{$num}{/capture}
{global_content name=$blobname}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: [SOLVED!] Random blocks of text
{capture assign='blobname'}blob{1|rand:3}{/capture}
{global_content name="$blobname"}
{global_content name="$blobname"}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
-
- Forum Members
- Posts: 247
- Joined: Sun Oct 28, 2007 4:14 am
Re: [SOLVED!] Random blocks of text
Programmers! 
Thanks calguy

Thanks calguy