PDA

View Full Version : How do I add a second simple rotating banner?


Fredrik_Arvid
04-02-2008, 09:31 AM
Hello,

I use this script for a simple rotating banner in the header:
http://www.vbulletin.com/forum/showthread.php?t=170826

And it works fine.

Now I am trying to put a second rotating banner after the firts post in every thread.
But it does not work. Nothing shows up.

I am replacing all instances of $random_banner with $random_banner2:


$random_number = rand(1, 4);

$random_banner2[1] = '<a href="http://www.mysite.com"><img src="http://www.mysite.com/banner1.gif" alt="" border="0" /></a>';
$random_banner2[2] = '<a href="http://www.mysite.com"><img src="http://www.mysite.com/banner2.gif" alt="" border="0" /></a>';
$random_banner2[3] = '<a href="http://www.mysite.com"><img src="http://www.mysite.com/banner3.gif" alt="" border="0" /></a>';
$random_banner2[4] = '<a href="http://www.mysite.com"><img src="http://www.mysite.com/banner4.gif" alt="" border="0" /></a>';


And I use this code to displaying the random banner:

$random_banner2[$random_number]

But it doesn?t work! It?s just empty. Am I doing something wrong?

Please help me!

Regards,
Fredrik_Arvid

Dismounted
04-02-2008, 11:48 AM
Try this:
$random_number2 = rand(1, 4);

$random_banner2[1] = '<a href="http://www.mysite.com"><img src="http://www.mysite.com/banner1.gif" alt="" border="0" /></a>';
$random_banner2[2] = '<a href="http://www.mysite.com"><img src="http://www.mysite.com/banner2.gif" alt="" border="0" /></a>';
$random_banner2[3] = '<a href="http://www.mysite.com"><img src="http://www.mysite.com/banner3.gif" alt="" border="0" /></a>';
$random_banner2[4] = '<a href="http://www.mysite.com"><img src="http://www.mysite.com/banner4.gif" alt="" border="0" /></a>';
Then this to display:
$random_banner2[$random_number2]
If that does not work, where are you putting each of the code blocks?

Fredrik_Arvid
04-02-2008, 01:36 PM
Hello Dismounted,
I tried your solution but that did not work.

I am putting the code block in
Admin CP -> Styles & Templates -> Style Manager -> ? ? -> Postbit Templates -> postbit
at the very bottom:

<!-- / post $post[postid] popup menu -->
<if condition="$post[postcount] == 1 AND $GLOBALS[threadinfo][replycount] >= 2">

<div style="padding: $stylevar[cellpadding]px 0px 0px 0px">

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="thead" align="left">Annons</td>
</tr>
<tr>
<td class="alt1" align="center">
$random_banner[$random_number]

</td>
</tr>
</table>
</div>
</if>

I am using this thing described at vbulletin.com: How To Show A Banner After The First Post In A Thread (http://www.vbulletin.com/forum/showthread.php?t=198875)

(I have got the first simple banner rotator - the one that works fine - in the footer template.)

Dismounted
04-03-2008, 05:34 AM
Where are you putting the code block (PHP code)?

Fredrik_Arvid
04-03-2008, 07:58 AM
I am putting it as a new plugin in: Plugin & Products System

Dismounted
04-03-2008, 08:24 AM
At which hook?

Fredrik_Arvid
04-03-2008, 08:42 AM
Hook location: parse_templates

Fredrik_Arvid
04-05-2008, 05:13 AM
Is it OK to put it in the pare_templates?

Dismounted
04-05-2008, 09:42 AM
Try changing to hook location to global_start.

Fredrik_Arvid
04-07-2008, 02:40 PM
Try changing to hook location to global_start.

It didn`t work.

Dismounted
04-08-2008, 06:39 AM
Try postbit_display_complete.

Fredrik_Arvid
04-08-2008, 09:57 AM
Try postbit_display_complete.

Yeah that is working!!:)

I put this code inte the postbit-template:

$random_banner2[$random_number]


And this for hook-location:
postbit_display_complete

Thank you very much for your help!

Best regards,

Fredrik Arvidsson

f4vn
07-18-2008, 08:33 PM
I try for only first post but it doesn`t work and have a error "Parse error: syntax error, unexpected T_STRING in /xxx/includes/class_postbit.php(293) : eval()'d code on line 4"

Dismounted
07-19-2008, 04:11 AM
Most likely, you have unescaped quotes. Please post your code.

jkcerda
07-19-2008, 04:22 AM
posting here just so that I can track later.
looks interesting BTW.