/**
 * If you want to go a step further, you can create your own custom WordPress loop for your component.
 * By doing this you could output a number of items within a loop, just as you would output a number
 * of blog posts within a standard WordPress loop.
 *
 * The example template class below would allow you do the following in the template file:
 *
 * 	<?php if ( bp_get_example_has_items() ) : ?>
 *
 *		<?php while ( bp_get_example_items() ) : bp_get_example_the_item(); ?>
 *
 *			<p><?php bp_get_example_item_name() ?></p>
 *
 *		<?php endwhile; ?>
 *
 *	<?php else : ?>
 *
 *		<p class="error">No items!</p>
 *
 *	<?php endif; ?>
 *
 * Obviously, you'd want to be more specific than the word 'item'.
 *
 * In our example here, we've used a custom post type for storing and fetching our content. Though
 * the custom post type method is recommended, you can also create custom database tables for this
 * purpose. See bp-example-classes.php for more details.
 *
 */
function bp_example_has_items($args = '')
{
    global $bp, $items_template;
    // This keeps us from firing the query more than once
    if (empty($items_template)) {
        /***
         * This function should accept arguments passes as a string, just the same
         * way a 'query_posts()' call accepts parameters.
         * At a minimum you should accept 'per_page' and 'max' parameters to determine
         * the number of items to show per page, and the total number to return.
         *
         * e.g. bp_get_example_has_items( 'per_page=10&max=50' );
         */
        /***
         * Set the defaults for the parameters you are accepting via the "bp_get_example_has_items()"
         * function call
         */
        $defaults = array('high_fiver_id' => 0, 'recipient_id' => 0, 'per_page' => 10, 'paged' => 1);
        /***
         * This function will extract all the parameters passed in the string, and turn them into
         * proper variables you can use in the code - $per_page, $max
         */
        $r = wp_parse_args($args, $defaults);
        extract($r, EXTR_SKIP);
        $items_template = new BP_Example_Highfive();
        $items_template->get($r);
    }
    return $items_template->have_posts();
}