Jump to content

Migrating from 'st' to 'page' repetitive code.... why?

Featured Replies

Posted

http://www.invisionpower.com/support/guides/_/advanced-and-developers/miscellaneous/34-migrating-from-st-to-page-r231

You'll likely want to add a helper method like so:

:unsure: .... is there a reason there isn't some standard methods in the output class or IPSLib as it is really basic code you ask us to add to every script using paging repeating the same thing over again?

/**
 * Coverts a page number to a start value
 * @param int $page
 * @param int $perPage
 */
public function pageToSt( $page, $perPage )
{
	$page = intval( $page );
        $perPage = intval( $perPage );
	return ( $page > 1 ) ? ( ( $page - 1 ) * $perPage ) : 0;
}


/**
 * Coverts a st value to a page number
 * @param int $page
 * @param int $perPage
 */
public function stToPage( $st, $perPage )
{
	$st = intval( $st );
        $perPage = intval( $perPage );
	return ( $st > 0 ) ? ( ceil( $st / $perPage ) + 1 ) : 1;
}

:flowers: Just asking, not like I could depend on such being there now... just is annoying to have the same methods rolled into every script to call them.

Seems like it would be something that could be easily included in IPSLib for easy re-use in other products.

I did wonder about this, seems silly to keep reproducing the same method.

Archived

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

Recently Browsing 0

  • No registered users viewing this page.