Skip to content

Instantly share code, notes, and snippets.

@justrjlewis
Last active December 30, 2015 12:08
Show Gist options
  • Save justrjlewis/7826722 to your computer and use it in GitHub Desktop.
Save justrjlewis/7826722 to your computer and use it in GitHub Desktop.
Sorting Concrete5 stack contents in reverse order.
<?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