Would you please consider change the - (skeleton) from:
class _{controller} extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
{restriction}
parent::execute();
}
/**
* Manage
*
* @return void
*/
protected function manage()
{
/* Create the table */
$table = new \IPS\Helpers\Table\Db( '{table_name}', \IPS\Http\Url::internal( 'app={app}&module={module}&controller={controller}' ) );
/* Display */
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'title', (string) $table );
}
}
to:
class _{controller} extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
{restriction}
parent::execute();
}
/**
* Manage
*
* @return void
*/
protected function manage()
{
/* Create the table */
$table = new \IPS\Helpers\Table\Db( '{table_name}', $this->url() );
/* Display */
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'title', (string) $table );
}
public function url()
{
return \IPS\Http\Url::internal( 'app={app}&module={module}&controller={controller}' );
}
}
This is basically to avoid use several times \IPS\Http\Url::internal( 'app=...' ) in same file. That would make things easier/faster when using the URLs in Admin table controllers.
A few examples:
- Row buttons:
$table->rowButtons = function( $row )
{
$return = array(
'edit' => array(
'title' => 'edit',
'icon' => 'pencil',
'link' => $this->url()->setQueryString( 'id', $row['id'] ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('group_editing') )
),
);
$return['delete'] = array(
'title' => 'sign_out',
'icon' => 'times',
'link' => $this->url()->setQueryString( array( 'id' => $row['id'] ) )->csrf(),
'data' => array( 'delete' => '' )
);
return $return;
};
- Action buttons:
\IPS\Output::i()->sidebar['actions']['add'] = array(
'primary' => true,
'title' => 'add',
'icon' => 'plus',
'link' => $this->url()->setQueryString( array( 'do' => 'form' ) ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add') )
);
- Redirects:
\IPS\Output::i()->redirect( $this->url(), 'saved' );
- Links:
$link = ' <a href="' . $this->url() . '">' . \IPS\Member::loggedIn()->language()->addToStack( 'member_view_full_list' ) . '</a>';
Of course this can be handled by devs if they wish to optimize their code but again, this is just a suggestion for an enhancement in the skeleton.