Created
December 5, 2012 14:20
-
-
Save adamkiss/4215822 to your computer and use it in GitHub Desktop.
EE's 'switch' – template function in pure PHP
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 | |
$ee_switch_global = array(); | |
function switch(){ | |
global $ee_switch_global; | |
$args = func_get_args(); | |
$key = array_shift($args); | |
if (array_key_exists($key,$ee_switch_global)){ | |
$index = $ee_switch_global[$key]++; | |
if ($index === count($args)) | |
$ee_switch_global[$key]=0; | |
$return $args[$index]; | |
}else{ | |
$ee_switch_global[$key]=1; | |
return $args[0]; | |
} | |
} | |
?> | |
<div class="<?=switch('columns','left','center','right');?>"> | |
<!-- content --> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment