PDA


View Full Version : Random Content in VBA CMPS Module


HellRazor
11-12-2005, 01:49 AM
This module is based off a random content thread I found over at vbulletin.org.

1. Upload the following file to your forum directory under the name content.txt (these are just a few quotes, but you can change the file to contain whatever random content you want to display):


"I know the price of success; dedication, hard work and an unremitting devotion to the things you want to see happen."--Frank Lloyd Wright
"What makes life dreary is want of motive."--George Eliot
“Doing business without advertising is like winking at a girl in the dark. You know you’re doing it but nobody else does."--Steuart Henderson Brit


2. Upload the following file to your forum directory under the name rand_con.php (edit the $file = path to the path you saved content.txt):


<?php
$file = "http://www.yourdomain.com/forums/content.txt";
$fp = file($file);
srand((double)microtime()*1000000);
$random_content = $fp[array_rand($fp)];
echo "$random_content";
?>


3. In your admincp, go to Plugin System, then Add New Plugin. Add the following plugin:

Hook Location: global_start
Title: Random Content
Plugin PHP Code:


ob_start();
include('rand_con.php');
$random_content = ob_get_contents();
ob_end_clean();


4. Add a new template:

Title: adv_portal_random_content
Template:


<tr>
<td class="thead"><span class="smallfont"></span></td>
</tr>
<tr>
<td class="$altbgclass"><span class="smallfont"></span></td>
</tr>
<tr>
<td class="$bgclass"><span class="smallfont">$random_content
</span></td>
</tr>


5. Finally, go to VBA CMPS, Add Module, choose 'Template', and add the following:

Module Name: Random Content
Template to include: random_content
Use Module Shell Template: Yes

You should now have a module that displays random text from the content.txt file.

Bluejacket
03-08-2006, 06:21 AM
Hi, I wanted to say I just did this on my site and it works perfectly. Thanks for taking the time to post it. :)

halpern
05-15-2006, 04:23 PM
Is there a scrolling feature to this module so it scrolls the quote and then when you hover over it the quotes stop?

halpern
05-15-2006, 06:17 PM
The HTML is messed up..

All you need in the template code is this: (correct me if I am wrong)


<tr>
<td class="$altbgclass"><span class="smallfont">$random_content</span>
</tr>


The other code adds the $random_content into a different table which messes up the colors.


Is there anyway to make this more random? It doesn't seem to be taking in all of the quotes I have in the .txt file?

ikastara
10-16-2008, 04:52 AM
hello,
I tried installing this

in the module preview it works fine
but when I view in the homepage the quotes doesn't show
only the module header and no quote....

where could it be wrong?

mjname
11-19-2008, 05:17 PM
I am having the same issue it works in the module preview, works great, but on the home page it doesn't show the quote just the module table.

eJM
11-24-2008, 01:35 AM
Why are you guys messing around with a module that was developed in 2005 and the author hasn't been on the site since 05-31-2008?

Jim

CareyCrew
11-24-2008, 04:11 AM
Indeed Jim, this mod was for CMPS v2 and vBulletin 3 was just starting out.

Given all the changes in vB and vBA is it likely to work now without a rewrite?

seriestv
11-28-2008, 02:37 PM
Is not working on 3.0 and vb3.

HOw can I doit in 3.01?