Jump to content
php.lv forumi

RANDOM FLASH BANNER


kasparitos

Recommended Posts

Šitas man stāv iekš modules>>blockus2

 

BOLCKUS2.PHP

<?

class Blockus2 extends Module
{
public function __construct()
{
	$this->name = 'blockus2';
	$this->tab = 'Blocks';
	$this->version = 1.0;

	parent::__construct();

	/* The parent construct is required for translations */
	$this->page = basename(__FILE__, '.php');
	$this->displayName = $this->l('Us2 block');
	$this->description = $this->l('Adds a block with several us2 links');
}

function install()
{
	if (!parent::install() OR !$this->registerHook('rightColumn'))
		return false;
	return true;
}

function hookLeftColumn($params)
{
	return $this->display(__FILE__, 'blockus2.php');
}

function hookRightColumn($params)
{
	return $this->hookLeftColumn($params);
}
}
?>

BLOCKUS2.TPL

<!-- Block us2 module -->
<div id="us2_block_right" class="block">
<h4>{l s='REKLĀMA' mod='blocus2'}</h4>
<ul class="block_content">

</ul>		
</div>
<!-- /Block us2 module -->

 

KUR LAI ES IEVIETOJU ŠITO CEDE PHP ??

		<?php
$imglist='';
//$img_folder is the variable that holds the path to the swf files.
// see that you dont forget about the "/" at the end
$img_folder = "images/";
mt_srand((double)microtime()*1000);
//use the directory class
$imgs = dir($img_folder);
//read all files from the directory, ad them to a list
while ($file = $imgs->read()) {
if (eregi("swf", $file))
$imglist .= "$file ";
} closedir($imgs->handle);
//put all images into an array
$imglist = explode(" ", $imglist);
$no = sizeof($imglist)-2;
//generate a random number between 0 and the number of images
$random = mt_rand(0, $no);
$image = $imglist[$random];
//display random swf
echo '<embed src="'.$img_folder.$image.'" quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="520"
height="120"></embed>';
?>

Edited by kasparitos
Link to comment
Share on other sites

kasparitos: nevajag tāpēc uzreiz bļaut. Protams, ka vajag palīdzēt cilvēkiem. Bet ne jau priekšā visu izdarīt. Ja tu pats saproti, ko dari, tad tev nevajadzētu būt problēmām pielietot p4F ieteikto funkciju.

Nezinu neko par tpl failiem, bet tev vienkārši tur vajag php kodā ar rand funkciju izvēlēties savu random flaš banneri, un attiecīgo mainīgo izmantot tpl failā, lai to izvadītu html'ā. Ļoti vienkārši. Ko tu tieši nesaproti no tā?

Link to comment
Share on other sites

×
×
  • Create New...