PDA

View Full Version : Simplest banner/quotes/links rotator !! How to do it for vB4??


valdet
09-03-2010, 10:29 AM
Hi,
I want to use this basic banner rotator on one of my test vB4 installations.

http://www.vbulletin.com/forum/showthread.php?170826-How-To-Implement-A-Simple-Random-Banner

I had been using it with no problems in vB3 but now that vB4 syntax has changed, it doesn't work anymore.

On vb3 I had used $random_banner[$random_number] as above and it worked great, but this variable doesn't get parsed through vb4 plugins anymore.

I appreciate if you can help me what is the correct use of this example in vB4 environment.

Thank you.

Lynne
09-06-2010, 01:36 PM
All variables must now be preregistered for use in a 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)

valdet
09-08-2010, 07:39 AM
Thank you very much Lynne,

I had to add a little bit more and actually change the plugin code to a simpler version.

Inside the plugin I had to create a third variable $new_banners and only pre-registered that variable within template and ran it through parse_templates hook
$random_number = mt_rand(1, 5);

$random_banner[1] = '<img src="path/to/banner1.gif" alt="" border="0" />';
$random_banner[2] = '<img src="path/to/banner2.gif" alt="" border="0" />';
$random_banner[3] = '<img src="path/to/banner3.gif" alt="" border="0" />';
$random_banner[4] = '<img src="path/to/banner4.gif" alt="" border="0" />';
$random_banner[5] = '<img src="path/to/banner5.gif" alt="" border="0" />';

$new_banners = $random_banner[$random_number];

vB_Template::preRegister('navbar',array('new_banne rs' => $new_banners)); To make it work, I just dropped this code {vb:raw new_banners} on the template and now it works just as before under vB3.x.

I appreciate your help and borbole (https://vborg.vbsupport.ru/member.php?u=369511) for helping me through this.

I hope other users find this little experience useful in their sites.

muimui
08-30-2013, 02:53 PM
its not working on vb4.2 version