Home » Documentation » What is PeoplePods? » SDK Documentation » Stacks » $Stack->output()

$Stack->output()

$Stack->output($template_name);

Outputs the contents of the entire stack with special formatting variables made available to the templates. If $template_name is specified, a template of that name from the appropriate theme folder will be used. Otherwise, the default 'output' template is used.

$person->friends()->output('short');

When outputted through a stack, each object in the list gets special formatting variables available in the template which pertain to the item's position in the list:

  • isFirstItem - boolean
  • isEvenItem - boolean
  • isOddItem - boolean
  • isLastItem - boolean
  • listCount - numeric position in stack, starting at 1
  • isThirdItem, isFourthItem,isFifthItem,isSixthItem,isSeventhItem,isEigthItem,isNinthItem - is item the Nth item? True for every Nth item

In templates, you can access these as if they were normal fields:

// in template file
if ($content->get('isFirstItem')) { 
  // do something special for the first item
}

By default, stacks wrap their output in a simple header and footer template, located in the theme folder under the stacks sub-folder. You can override this by passing in a few extra parameters:

// no header or footer
$stack->output('short',null,null);

// use the normal header, 
// but swap in the pagination footer
$stack->output('short','header','pager');

Finally, you can specify a title and an empty message to be displayed in the header and footer templates:

$stack->output('short','header','pager','Search Results','No results!');
  • Discuss This Document

I am more and more appreciative of the work you have done here the more I look around. A request: it would be wonderful to know where all of these base and derived classes are actually implemented with a link to the section of actual source or location in the classes manifest. I realize there is probably a simple answer, but it illudes me for the moment while I study your good work.

Download Download the latest version of PeoplePods!

0.9 Latest Version:
Release Notes

Join the PeoplePods developer network and get direct access to documentation, additional plugins, and our forums!

  Already Registered? Login

Recent Posts from Our Blog

Version 0.9 is here!

The latest version of PeoplePods is now available for download! This version features a drastically revamped theme which is now valid HTML5, a completely rewritten JSON-powered API, many...

Ben Brown on how running a community is like throwing a giant, never-ending party

An interview I did with OpenSource.com is now online!  Read it here. In it, I discuss how running an online community is like throwing a giant, never-ending party, how open source techniques...