PDA

View Full Version : vBAdvanced - <?php include("file.php"); ?>


Liquid1ce
09-05-2004, 10:55 AM
Im using vBAdvanced & i have a php script that fetches data from a site a spits it out onto mine, but if i create a template on vbadvanced and put <?php include("file.php"); ?> nothing shows up.

& i need to do this with around 8 pages - Any one tell me how to do this

Regards

rake
09-05-2004, 01:01 PM
you can't use php code in templates, besides what you use in template conditionals.

SamirDarji
09-05-2004, 10:24 PM
Here's a link to a thread on vbadvanced.com on how to do just that: http://www.vbadvanced.com/forum/showthread.php?t=1082

Now, I've got a question that I've searched through this site and vbadvanced for the answer with no luck. How many variables can be passed to a template from php? I got 1 to work fine, but more than one is causing problems. I've actually posted to the same thread I gave you the link to. I'm racking my brain pretty good. This hurts!

rake
09-06-2004, 12:10 AM
what do you mean by passing variables to a template? You can use any number of variables within a template, assuming the variables exist in the php script from which the template is called

SamirDarji
09-06-2004, 12:19 AM
what do you mean by passing variables to a template? You can use any number of variables within a template, assuming the variables exist in the php script from which the template is called

Thank you for the quick response. That's what I was thinking, but for some reason, when I'm passing more than one, I get an IE "Unspecified error" message.

Here's a copy of the php script:


<?php
// Get a file into an array. In this example we'll go through HTTP to get
// the HTML source of a URL.

// This file is a listing of all thumbnail gifs with full path
// X:\FTP\MYPICS\YYMMDDXX.B\THUMBS\FILENAME.GIF
$fileArray = file('http://pics.huntsvillecarscene.com/events/testfile');

// Counts total number of lines in file to determine how many total pictures
$totalPics = count($fileArray);
//print "$totalPics\n";

// Line number of random line from file
$randomArray = array_rand($fileArray);
//print "$randomArray\n";
//print "$fileArray[$randomArray]\n";

// Truncates the first 14 and last 21 characters to eliminate the path
$picDirectory = substr($fileArray[$randomArray], 14, -22);
//print "$picDirectory\n";

// Get the root of the pic filename
$picFilename = substr(strchr($fileArray[$randomArray], "\\"),strrpos($fileArray[$randomArray], "\\")-1,-6);
//print $picFilename;

eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_randomevent') . '";');
?>


And then this is the html in the template:

<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<tr>
<td class="tcat"><span class="smallfont"><b>$vba_options[portal_blockbullet] Random Event Pic</b></span></td>
</tr>
<tr>
<td class="$getbgrow" width="100%">

<!-- Begin custom code -->
<center>
<!--
<img src="http://pics.huntsvillecarscene.com/events/$picDirectory/thumbs/$picFilename.gif">
-->
Pic $randomArray of $totalPics total pics on the server.
</center>
<!-- End custom code -->

</td>
</tr>
</table>
<br />


The whole thing is designed to pull random images off my picture server, which is only a win95 system running a very tiny and basic web server that does the job. There's over 5gb of pictures which I don't want to move into vb, but that I still can link to. I'm using this in conjunction with vbadvanced cmps for a module. Any help will be appreciated. I really wanted to finish this by today.

Liquid1ce
09-06-2004, 01:22 AM
thnx v/much for your help guys it works sweet :)

SamirDarji
09-06-2004, 01:47 AM
Hey, I got it working! Apparently there was some extra junk below the ending php tag that was causing some problems. Everything works great now. Too bad it's on my local test server, or I'd put up a link. :(