View Full Version : How would I put this statement in a side block?
Itworx4me
06-09-2004, 02:17 PM
I want to use this small little script in a side block. How would I go about doing this. Could someone explain the steps in order to make this work??
$images = array(
"Text" => array(
"Path/To/Image",
"Url/To/Site",
"Text"
),
);
srand ((float) microtime() * 10000000);
$random = array_rand($images,sizeof($images));
echo "<center>";
while(list($image,$link) = each($random))
echo "<!--// ".$images[$link][2]." //-->" .
"<a href='".$images[$link][1]."' class='friend' target='_blank'>" .
"<img src='".$images[$link][0]."' alt='".$images[$link][2]."' border='0px'>" .
"</a><br><br> ";
echo "</center>";
Thanks,
Itworx4me
Itworx4me
06-12-2004, 05:23 PM
bump
Merjawy
06-12-2004, 05:47 PM
I asked a question about html/php and the answer I got from Brian is that php needs to be used via files and not tempalte.. so try putting that in a file, upload it to your modules directry, when adding a module the file will be on the drop down list of files..
I have not looked at your code but just thats my understanding on how to run php modules :)
Brian
06-13-2004, 11:44 AM
http://vbadvanced.com/membersarea.php?do=viewmanual&productid=4 ;)
Itworx4me
06-14-2004, 12:15 AM
well I kinda got this to work but it places the file before the header and navbar. Here is what I have so far. Could someone tell me what is wrong with it???
.php file in the modules directory:
<?php
foreach ($modules AS $omods)
{
if ($omods['identifier'] == 'sponsorlist' AND in_array($omods['modid'], explode(',', $pages['modules'])))
{
$showsponsor = true;
$sponsorid = $omods['modid'];
}
}
$images = array(
"Text" => array(
"Path/To/Image",
"Url/To/Site",
"Text"
),
);
srand ((float) microtime() * 10000000);
$random = array_rand($images,sizeof($images));
echo "<center>";
while(list($image,$link) = each($random))
echo "<!--// ".$images[$link][2]." //-->" .
"<a href='".$images[$link][1]."' class='friend' target='_blank'>" .
"<img src='".$images[$link][0]."' alt='".$images[$link][2]."' border='0px'>" .
"</a><br><br> ";
echo "</center>";
eval('$home[$sponsorid][\'content\'] = "' . fetch_template('adv_portal_sponsors') . '";');
?>
Here is my template:
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder"width="100%">
<tr>
<td class="tcat"><span class="smallfont"><strong>$vba_options[portal_blockbullet] Sponsors</strong></span>
</td>
</tr>
<tr>
<td class="vbmenu_popup"><span class="smallfont">
<center>
$sponsorid
</span>
</td>
</tr>
</table>
</center>
<br />
Here are the settings for the vbcmps
Module Title: Sponsors
Module Identifier: sponsorlist
File to Include: sponsors.php
Active: Yes
Column: Right Column
Templates Used: adv_portal_sponsors
It just displays the images and links at the top of the site. Any help would be much apreciated.
Thanks,
Itworx4me
Brian
06-15-2004, 11:38 AM
foreach ($modules AS $omods)
{
if ($omods['identifier'] == 'sponsorlist' AND in_array($omods['modid'], explode(',', $pages['modules'])))
{
$showsponsor = true;
$sponsorid = $omods['modid'];
}
}
Why is this in there? You only need this code if you are trying to output two different modules with the same php file. You should remove that, and then change this line:
eval('$home[$sponsorid][\'content\'] = "' . fetch_template('adv_portal_sponsors') . '";');
To this:
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_sponsors') . '";');
Then this:
echo "<center>";
while(list($image,$link) = each($random))
echo "<!--// ".$images[$link][2]." //-->" .
"<a href='".$images[$link][1]."' class='friend' target='_blank'>" .
"<img src='".$images[$link][0]."' alt='".$images[$link][2]."' border='0px'>" .
"</a><br><br> ";
echo "</center>";
Needs to be changed to this:
while(list($image,$link) = each($random))
$sponsorid = "<!--// ".$images[$link][2]." //-->" .
"<a href='".$images[$link][1]."' class='friend' target='_blank'>" .
"<img src='".$images[$link][0]."' alt='".$images[$link][2]."' border='0px'>" .
"</a><br><br> ";
Itworx4me
06-15-2004, 06:27 PM
Thank Brian for the help. It worked great. If I wanted to add more then one array for the script to out put. How would I get this to print out all the arrays, like if there were 10 or so??
Thanks,
Itworx4me
Brian
06-16-2004, 11:24 AM
Are you saying 10 different modules, or just 10 different images in the same module?
Itworx4me
06-16-2004, 11:34 AM
Are you saying 10 different modules, or just 10 different images in the same module?
10 different images in the same block. The code above rotates images in a block everytime you refresh your page. As you have it now it only has one image that shows in the block. I want it to show all of the images in the side block.
Thanks again for your help Brian
Brian
06-16-2004, 11:38 AM
So that's just pulling random images from a specified folder?
Itworx4me
06-16-2004, 11:44 AM
Yes it pulls different images from a specific folder. Here is an example of what it does. Http://www.nsca-racing.com The Right side block is what I am using this script for.
I currently use vbportal but am getting ready to upgrade to vb3 and use cmps. This side block is the only thing holding me back from upgrading now. I have a test site set up so that I can get everything working correctly before upgrading so there isn't any down time for the site.
Thanks again for your help Brian
Brian
06-16-2004, 12:19 PM
Ahh, I think that was just a dumb mistake on my part. Try changing this:
$sponsorid =
To this:
$sponsorid .=
Itworx4me
06-16-2004, 12:43 PM
Thanks Brian that did the trick.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.