_page_rows

Definition:
function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {}

Given a top level page ID, display the nested hierarchy of sub-pages together with paging support

Parameters

  • unknown_type $children_pages
  • unknown_type $count
  • unknown_type $parent
  • unknown_type $level
  • unknown_type $pagenum
  • unknown_type $per_page
  • &$children_pages
  • &$count

Source code

function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {



	if ( ! isset( $children_pages[$parent] ) )

		return;



	$start = ($pagenum - 1) * $per_page;

	$end = $start + $per_page;



	foreach ( $children_pages[$parent] as $page ) {



		if ( $count >= $end )

			break;



		// If the page starts in a subtree, print the parents.

		if ( $count == $start && $page->post_parent > 0 ) {

			$my_parents = array();

			$my_parent = $page->post_parent;

			while ( $my_parent) {

				$my_parent = get_post($my_parent);

				$my_parents[] = $my_parent;

				if ( !$my_parent->post_parent )

					break;

				$my_parent = $my_parent->post_parent;

			}

			$num_parents = count($my_parents);

			while( $my_parent = array_pop($my_parents) ) {

				echo "\t" . display_page_row( $my_parent, $level - $num_parents );

				$num_parents--;

			}

		}



		if ( $count >= $start )

			echo "\t" . display_page_row( $page, $level );



		$count++;



		_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );

	}



	unset( $children_pages[$parent] ); //required in order to keep track of orphans

}

4351

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: