Jump to content

Problems with (Routes, Pagination, Handling Ajex calls)

Recommended Posts

- How to generate a table via the Table helper (similar to the one in the ACP Members page). Trying to create one from scratch messes up on the responsive view.

- Adding routes when developing plugins, specifically for the Account Settings page stuff.

- Pagination + tables, how to take data from the DB and display it in a paginated table, or at the very least, paginated ul/

- How to handle Ajax request calls to certain routes, both in the frontend and backend code


If my questions could be answered that would be a blessing as I am having some problems with these. Thank you in advance!

Link to comment
Share on other sites

Table helpers are fairly simple. When you say it messes up the responsive view, can you clarify the problems? You may need to add certain CSS classes to certain columns to control the overflowing. A barebones example would be something like

		/* Init Table */
		$table = new \IPS\Helpers\Table\Db( 'database_Table', $baseUrl, array( "somecolumn=?", 1 ) );
		/* Columns we need */
		$table->include = array( 'somecolumn', 'other_column' );
		$table->mainColumn = 'somecolumn';
		$table->langPrefix = 'lang_prefix_';

		$table->tableTemplate  = array( \IPS\Theme::i()->getTemplate( 'tables', 'core', 'admin' ), 'table' );
		$table->rowsTemplate  = array( \IPS\Theme::i()->getTemplate( 'tables', 'core', 'admin' ), 'rows' );
		/* Default sort options */
		$table->sortBy = $table->sortBy ?: 'somecolumn';
		$table->sortDirection = $table->sortDirection ?: 'desc';
		/* Custom parsers */
		$table->parsers = array(
			'somecolumn'	=> function( $val, $row )
				return $val
			'other_column'	=> function( $val, $row )
				return ( $val ) ? "<i class='fa fa-check'></i>" : "<i class='fa fa-times'></i>";
		/* Return */
		return (string) $table;


Routing is handled automatically, you just need to add the appropriate methods. 


Pagination is handled automatically if you use table helpers.


The front end uses jQuery, so you can easily send AJAX requests to the backend. On the backend you can then do something like this:

if( \IPS\Request::i()->isAjax() )
	// This is an AJAX request
	// This is not an AJAX request


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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