Last active
February 23, 2016 15:00
-
-
Save rdeutz/9058277 to your computer and use it in GitHub Desktop.
Show a number of modules form a larger number of modules randomly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$modlist=array('modpos01','modpos02','modpos03','modpos04','modpos05'); | |
$allMods=count($modlist); | |
$show=array(); | |
$elephantInCairo=0; | |
while(count($show) < 4 && $elephantInCairo < 100) | |
{ | |
$c = rand (0 , $allMods-1); | |
if (!in_array($modlist[$c], $show)) | |
{ | |
if ($this->countModules($modlist[$c])) | |
{ | |
$show[] = $modlist[$c]; | |
} | |
} | |
$elephantInCairo++; | |
} | |
?> | |
<?php if (count($show)): ?> | |
<section id="mymodulerow"> | |
<div class="container"> | |
<h3>My Module Row</h3> | |
<div class="row"> | |
<?php foreach($show as $m) : ?> | |
<div class="col-md-3"> | |
<jdoc:include type="modules" name="<?php echo $m; ?>" style="xhtml" /> | |
</div> | |
<?php endforeach; ?> | |
</div> | |
</div> | |
</section> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why not simply do: