This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

When developing custom builds, stacks are a powerful use case for giving clients the ability to put together blocks of content for their pages, but maybe the content needs to viewed by newest, or most recent first.

Some might say that this is a great scenario for a page-list template, but that is not always the case when put in terms of single-block content that doesn't need to live on its own page, but does need to be viewed en masse.

<?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') or something like that
  if ($page->isEditMode()) {
      $a->display($c);  //show regular while we're editing — we're changing what is shown to guests on the front end
  } 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 
    }
  }
?>

That's it! Hope this helps someone. :-)

Loading Conversation