vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Simplest banner/quotes/links rotator !! How to do it for vB4?? (https://vborg.vbsupport.ru/showthread.php?t=249848)

valdet 09-03-2010 10:29 AM

Simplest banner/quotes/links rotator !! How to do it for vB4??
 
Hi,
I want to use this basic banner rotator on one of my test vB4 installations.

http://www.vbulletin.com/forum/showt...-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

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
Quote:

$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 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


All times are GMT. The time now is 09:39 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01746 seconds
  • Memory Usage 1,725KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete