vBadvanced Forums  
Go Back   vBadvanced Forums > vBadvanced Products > vBadvanced CMPS > vBa CMPS v3.0 Support > "How Do I..." Questions

Reply
 
Thread Tools Display Modes
  #1  
Old 06-02-2010, 11:48 PM
Punktek Punktek is offline
Member
 
Join Date: Oct 2004
Posts: 32
Default Randomizing a Module - PHP Not Evaluating Variables

I am trying to create a module that will rotate a random banner/module title. Right now I have this (It is a plugin in the parse_templates hook) :

Code:
$array_titles = array("Hellwig Products", "GAYLORDS Lids");

$array_images = array("http://www.fordtruckclub.net/images/adspace/hellwig.png", "http://www.fordtruckclub.net/sponsors/gaylords/gl_150.png");

$array_url = array("http://www.hellwigproducts.com/", "http://www.gaylordslids.com/");

$random_number = rand(0, 1);
And have this in the module template:

Code:
<div style="padding-bottom:$vba_style[portal_vspace]px">
	<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
		<thead>
			<tr>
				<td class="tcat" colspan="$mods[colspan]">
				<if condition="$vba_style['portal_collapsemods']">
					<a href="#top" onclick="return toggle_collapse('module_$mods[collapse]')" style="float:$stylevar[right]"><img alt="" border="0" id="collapseimg_module_$mods[collapse]" src="$stylevar[imgdir_button]/collapse_tcat$modimgcollapse.gif" /></a>
				</if>
				<span class="smallfont"><strong>$vba_style[portal_blockbullet] <if condition="$mods['link']"><a href="$mods[link]">$array_titles[$random_number]</a><else />$array_titles[$random_number]</if></strong></span></td>
			</tr>
		</thead>
		<tbody id="collapseobj_module_$mods[collapse]" style="$modcollapse">
			<if condition="$show['tablerow']">
				<tr>
					<td class="$bgclass" style="background-color: #0A1225;">
					$array_images[$random_number]
					</td>
				</tr>
			<else />
				<a href="$array_url[$random_number]"><img src="$array_images[$random_number]" border="0" /></a>
			</if>
		</tbody>
	</table>
</div>
<if condition="$show['endform']"></form></if>
For some reason though, the variables aren't being evaluated, the module just looks like this:

module.png

So I'm not sure what I am doing wrong. Any help?
Reply With Quote
  #2  
Old 06-03-2010, 04:11 PM
Brian's Avatar
Brian Brian is offline
Administrator
 
Join Date: Jan 2004
Location: Georgia, USA
Posts: 34,240
Default

Try changing the hook location to something like global_start instead. I'm not sure if vB's templates will accept variables like that, so you may need to add something like this at the bottom of your plugin too and then change the variable in your template.

PHP Code:
$myrandom_img $array_images[$random_number];
$myrandom_url $array_url[$random_number]; 
__________________
Frequently Asked Questions
CMPS Users Manual

For vBadvanced software assistance, please use the support forums.
Unsolicted PMs, IMs, and email will not be responded to.
If you have a non-software related question or problem with your account, please submit a support ticket.
Reply With Quote
  #3  
Old 06-03-2010, 05:06 PM
Punktek Punktek is offline
Member
 
Join Date: Oct 2004
Posts: 32
Default

Quote:
Originally Posted by Brian View Post
Try changing the hook location to something like global_start instead. I'm not sure if vB's templates will accept variables like that, so you may need to add something like this at the bottom of your plugin too and then change the variable in your template.

PHP Code:
$myrandom_img $array_images[$random_number];
$myrandom_url $array_url[$random_number]; 
I actually figured out the problem, I simply forgot to add them to the globalized variables in the Admin CP in vBA options.

Thanks though!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to acess global variables within a module trbothead Troubleshooting & Problems 24 04-08-2008 01:36 PM
Questions - evaluating whether vBa is for me convergent "How Do I..." Questions 4 01-24-2006 03:27 PM
My first module - can't display variables. trana Troubleshooting / "How do I..." Questions 3 09-07-2005 10:19 AM
OK, I give up.... a CGI script from a PHP module using vb & vba variables. KW802 Troubleshooting / "How do I..." Questions 2 07-26-2004 01:36 PM


All times are GMT -4. The time now is 12:18 AM.

Forums Powered by vBulletin, Copyright ©2000-2009, Jelsoft Enterprises Ltd.
Please note that vBadvanced is in no way affiliated with Jelsoft Enterprises Ltd, nor will Jelsoft be able to provide any support for our products.