Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
BouncingXkala Posted July 30, 2018 Posted July 30, 2018 - 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!
bfarber Posted July 30, 2018 Posted July 30, 2018 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 } else { // This is not an AJAX request }
BouncingXkala Posted July 31, 2018 Author Posted July 31, 2018 Thank you for your help! If I encounter anything else I will let you know. Cheers!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.