Search

Not sure where to put this as it isn't really an extension, but more of a convenience library. I found it quite repetitive to implement pagination logic on all my admin index listing pages, so I thought I'd go ahead and toss it all in a library.

The code is all documented and on GitHub, but I'll commit a README.markdown later on.

Pretty simple to set up:

$totalRecords = 50;     // Typically the value of a MySQL SELECT COUNT(1) query against a data table.
$perPage      = 15;     // Usually a call to `Symphony::Configuration()->get('pagination_maximum_rows', 'symphony')`.
$pageKey      = 'page'; // For instance: http://www.mysite.com/articles/?page=3

$Pager = Pager::factory($totalRecords, $perPage, $pageKey);

$results = Symphony::Database()->fetch("
    SELECT
        `id`,
        `title` 
    FROM `my_table`
    ORDER BY `id` DESC '.$Pager->getLimit(true)
");

// more code here to display page data

$this->Form->appendChild($Pager->save()); // If being invoked through a backend page

Here's the URL to the repository: Symphony - Pager

Good job there.

Well, it is an extension after all. It adds a class and nothing more, but it is an extension.

Fair enough, then. I've updated the directory structure and added an extension driver class. This was originally part of my other WebHooks extension I'm currently writing. I thought this class was too useful to keep it bundled with the other extension.

Cheers!

Can a moderator please lock this thread? I've submitted the entry to the extensions archive and it created a duplicate thread: http://getsymphony.com/discuss/thread/76991/

Thanks!

To be honest I don't think this needs to be an extension. It's more of a useful snippet that people will use in their code...

Yeah, kind of a grey area. I can see myself using this with other extensions, so it makes sense for me to encapsulate it this way. Makes it easier for me to check if it exists in this form; just call Symphony::ExtensionManager()->fetchStatus('pager'). This way it'll always be in the same location.

Either way, it's nothing complex or special and it's up there for people to use as they like.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details