PDA

View Full Version : Please help!


ThePimp
02-10-2006, 08:10 PM
Here's what I'm trying to do in the threadbit template:
<if condition="SOME CODE TO GENERATE A RANDOM CHANCE 1:50">
<if condition="$show['gotonewpost']">
<strong><a href="SPONSOR URL" id="thread_title_$thread[realthreadid]">$thread[threadtitle]</a></strong>
<else />
<a href="SPONSOR URL" id="thread_title_$thread[realthreadid]">$thread[threadtitle]</a>
</if>
<else />
<if condition="$show['gotonewpost']">
<strong><a href="showthread.php?$session[sessionurl]t=$thread[threadid]$thread[highlight]" id="thread_title_$thread[realthreadid]">$thread[threadtitle]</a></strong>
<else />
<a href="showthread.php?$session[sessionurl]t=$thread[threadid]$thread[highlight]" id="thread_title_$thread[realthreadid]">$thread[threadtitle]</a>
</if>
</if>

In essence, I want to show a sponsor's blind link in place of the thread URL on a 1:50 chance. I'm not really sure of the most efficient way, or how to carry this objective out.

Pleeease help.

Thank you.

Logikos
02-11-2006, 06:39 AM
Cheap way to do it:

PHP CODE
Using this will add a value to $random. That value can be anywhere between the #1 threw the #5.

$random = rand(1, 5);


Template Condition can be...

<if condition="$random == '3'">
<if condition="$show['gotonewpost']">
<strong><a href="SPONSOR URL" id="thread_title_$thread[realthreadid]">$thread[threadtitle]</a></strong>
<else />
<a href="SPONSOR URL" id="thread_title_$thread[realthreadid]">$thread[threadtitle]</a>
</if>
<else />
<if condition="$show['gotonewpost']">
<strong><a href="showthread.php?$session[sessionurl]t=$thread[threadid]$thread[highlight]" id="thread_title_$thread[realthreadid]">$thread[threadtitle]</a></strong>
<else />
<a href="showthread.php?$session[sessionurl]t=$thread[threadid]$thread[highlight]" id="thread_title_$thread[realthreadid]">$thread[threadtitle]</a>
</if>
</if>


That will make it a 1 & 5 chance that the value of $random will be equaled to 3. Maybe this can give you a tip in the right direction :ermm:

ThePimp
02-11-2006, 03:44 PM
Cheap way to do it:

PHP CODE
Using this will add a value to $random. That value can be anywhere between the #1 threw the #5.

$random = rand(1, 5);


Template Condition can be...

<if condition="$random == '3'">
<if condition="$show['gotonewpost']">
<strong><a href="SPONSOR URL" id="thread_title_$thread[realthreadid]">$thread[threadtitle]</a></strong>
<else />
<a href="SPONSOR URL" id="thread_title_$thread[realthreadid]">$thread[threadtitle]</a>
</if>
<else />
<if condition="$show['gotonewpost']">
<strong><a href="showthread.php?$session[sessionurl]t=$thread[threadid]$thread[highlight]" id="thread_title_$thread[realthreadid]">$thread[threadtitle]</a></strong>
<else />
<a href="showthread.php?$session[sessionurl]t=$thread[threadid]$thread[highlight]" id="thread_title_$thread[realthreadid]">$thread[threadtitle]</a>
</if>
</if>


That will make it a 1 & 5 chance that the value of $random will be equaled to 3. Maybe this can give you a tip in the right direction :ermm:

Cool thanks.

Just tried it out... Doesn't seem to be outputting the sponsor link.

Here's what I did...
1. Added a New Plugin via the Plugin Manager
2. This new plugin is called randNum and it contains this code:
$random = rand(1, 5);
3. I set this to be called in the global_start.
4. I edited the template with the above template edit.

Doesn't seem to be displaying the sponsor URL.

Any ideas?

EDIT: Nevermind. I think I got it working. Thanks for your help! This RULES!

Logikos
02-11-2006, 07:31 PM
No problem, remember its random. Sometimes it won't show up. ;)