Hello everyone,
I'm trying to get to grips with developing applications in IPS so I can help out in a Community that runs IPS.
In the process, I have found myself trying to create and display a table using the IPS Table Helper. I have ran into a bit of an issue though, here is my code:
$baseUrl = new \IPS\Http\Url('url', false);
$table = new \IPS\Helpers\Table\Db('table_name', $baseUrl);
$table->rowsTemplate = [\IPS\Theme::i()->getTemplate('tables', 'core', 'admin'), 'rows'];
$table->tableTemplate = [\IPS\Theme::i()->getTemplate('tables', 'core', 'admin'), 'table'];
$table->limit = 25;
\IPS\Output::i()->output .= $table;
I would imagine that it would be rather simple and straightforward. However, when it comes to running this code using the appropriate do method in my application, an error is thrown:
Extract from the Whoops Error handler:
/IPS/system/Helpers/Table/Table.php
$this->sortDirection = ( mb_strtolower( \IPS\Request::i()->sortdirection ) === 'desc' or mb_strtolower( \IPS\Request::i()->sortdirection ) === 'asc' ) ? mb_strtolower( \IPS\Request::i()->sortdirection ) : NULL;
}
/* Filter? */
if ( \IPS\Request::i()->filter )
{
$this->filter = \IPS\Request::i()->filter;
}
/* Set base URL */
$this->baseUrl = $baseUrl->setQueryString( array( 'filter' => $this->filter, 'sortby' => $this->sortBy, 'sortdirection' => $this->sortDirection ) )->setPage( $this->paginationKey, $this->page );
/* Templates */
$this->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'tables', 'core' ), 'table' );
$this->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'tables', 'core' ), 'rows' );
/* Create a unique id used by the template - can be overriden manually if desired */
$this->uniqueId = md5( mt_rand() );
}
I have been reading the Documentation for IPS 4.4 from here: https://codingjungle.com/phpdoc/40400/
There is no mention of the existance of a method called setPage in the \IPS\Http\Url class so it's safe to say that I'm pretty confused right now.
Any input or ideas on how to work around this would be greatly appreciated. Cheers!