Forums / Cotonti / Skins / Random Slider for DarkPortal

ToM
#27747 2011-01-04 18:15
This is function for random picture/screen in slider that use <li></li> tags. It is designed for Dark Portal skin . I saw few question on Cotonti forom about random pictures in Dark Portal skin.


1.
------
EDIT:
(put in tpl file) index.tpl

{SLIDER_SHOW}

(instead of)

{PHP.cfg.freetext8}


2.
------
ADD:
(into file) index.inc.php (in system\core\index) bellow "$t = new XTemplate($mskin);" line:


function rnd_slider($fragments)
{

$fragment_count = 0;
$fragment_rndmatch_counter = 0;
$fragment_rndmatch = array("");


$rnd_number = 0;
$rnd_match = 0;
$rnd_dismatch_countr = 0;
$rndmatch = array("");

$slider_rnd_content = array("");


preg_match_all('/.*/',$fragments,$slider_fragmenty_prepare);

$slider_fragmenty_join = join("", $slider_fragmenty_prepare[0]);

preg_match_all('/\<li.+?li>/',$slider_fragmenty_join,$slider_fragmenty_parse);

$fragment_count = count($slider_fragmenty_parse[0]);

while ($fragment_rndmatch_counter < $fragment_count)
{

$rnd_match = 0;
$rnd_number = mt_rand(1,$fragment_count);

for ($rnd_dismatch_countr = 0; $rnd_dismatch_countr < $fragment_count; )
{

if ($rndmatch[$rnd_dismatch_countr] != $rnd_number)
{
$rnd_dismatch_countr++;
}
else
{
$rnd_match = 1;
break;
}
}

if ($rnd_match == 0)
{
array_push($rndmatch,$rnd_number);

$fragment_rndmatch_counter++;

array_push($slider_rnd_content,$slider_fragmenty_parse[0][($rnd_number -1)]);
}
}

return $slider_rnd_content;

}

$t->assign("SLIDER_SHOW", join("",rnd_slider($cfg['freetext8'])));

==================================================================
This is just function that could be useful for any user but it would be grateful if somebody is able to make a plug-in from it maybe :) .
Salvation is the gift but sometimes is to hard for us to acknowledge it.