Jump to content

rootsPerPage


Recommended Posts

When using $rootsPerPage for a Tree, it's still showing every root on the same page in acp. It shows the pagination correctly (ie, I have 88 rows, set it to 10, it shows there are 9 pages), but then every page simply lists all 88 roots. For this app, no subcategories are even allowed and it could have a lot of roots, so I figured I should have it broken into pages, especially since I don't see much reason for anyone to reorder them, anyway.

I can't remember if I confirmed it working in the past or maybe it has just always been this way.

I see the line in Tree.php that gets the rows and it sure seems like it's correct...

Edited by Midnight Modding
Link to comment
Share on other sites

9 hours ago, Daniel F said:

Have you also defined the getTotalRoots callback function?

In the tree.php:

	/**
	 * @brief	If using $rootsPerPage, a callback function that returns the total number of roots
	 */
	public $getTotalRoots = NULL;

 

yes. I see what the problem is.

Quote

$rows = $getRootsFunction( $this->rootsPerPage ? array( ( $page - 1 ) * $this->rootsPerPage, $this->rootsPerPage ) : NULL );

I don't see a code button in the editor, but anyway, in that line there from Tree.php, it's passing that array or null to $this->getRoots(), but getRoots() does not even use any parameters.

So I did my own _getRoots() method and changed the following line:

Quote

foreach( $nodeClass::roots( NULL ) as $node )

to:

Quote

foreach( $nodeClass::roots( NULL, NULL, array(), $extra ) as $node )

where $extra is the passed array from above. SO now it works.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...