Last active
December 30, 2015 12:08
-
-
Save justrjlewis/7826722 to your computer and use it in GitHub Desktop.
Sorting Concrete5 stack contents in reverse order.
This file contains 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 | |
$a = new GlobalArea('Your Area Name'); //since I normally do this within a block, I append something unique to these such as a blockID, or custom user input instead of( 'Your Area Name') it's ($variable.' Your Area Name') | |
if ($page->isEditMode()) { | |
$a->display($c); //show regular while we're editing — we're changing what is shown on the page | |
} else { | |
$stacks = Stack::getByName('Your Area Name'); | |
$blocks = $stacks->getBlocks(); | |
krsort($blocks); //reverse sort the blocks in the stack | |
foreach($blocks as $block) { | |
$block->display(); //display the newly sorted blocks | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment