PDA

View Full Version : PHP Random not working


Kestryll
03-10-2014, 10:57 PM
I currently run a large forum on 3.8.7 and am looking to upgrade to 4.2.2.
I have set up a test site on the same server and DB server as my main site.

I run in house advertising via a table in the header that calls to plugins using the PHP random feature like this:
In Table in header:
<td style="width: 120px; text-align: center; height: 60px;">$random_banner12[$random_number12]</td>

In plug ins with a hook location of 'parse_templates' Execution order 5
$random_number12 = rand(1, 3);

$random_banner12[1] = '<a href="http://www.vendor/" target="_blank"><img src="/images/ads12/vendor.gif" alt="" border="0" /></a>';

These are set up identically to my current 3.8.7 install, in fact much of it is cut and paste.
While the table shows on the 4.2.2 forum pages the plug ins are not working, all that comes up in the table is the coding.
I asked on the vBulletin customer forum and was told they had made changes and this coding wouldn't work.

Is there something similar out that will work with vB4?

Lynne
03-11-2014, 12:19 AM
You need to register the variable for use in the template.

Cellarius wrote a really good article that you may be interested in - [vB4] Rendering templates and registering variables - a short guide (https://vborg.vbsupport.ru/showthread.php?t=228078)