Jump to content

Help with creating pagination


Tom S.
 Share

Go to solution Solved by Ilya Hoilik,

Recommended Posts

I have a list of items

<ul>
  <li>item 1</li>
  <li>item 2</li>
  <li>item 3</li>
  <li>item 4</li>
  <li>item 5</li>
</ul>

I see you have a UI widdget: ips.ui.pagination

Am I correct in assuming this widget can create pagination of the above list?

If so, how can I implement it? I can't work it out from that guide.

Thank you.

 

 

Link to comment
Share on other sites

1 hour ago, bfarber said:

Personally, I would recommend you just call the pagination HTML template and pass in the appropriate values.


{template="pagination" group="global" app="core" location="global" params="$baseUrl, $totalPages, $currentPage, $limit, TRUE, 'page'"}

 

I'm not working inside templates (using my own PHP script). Is there a way I can call that template from within the PHP script?

I'm thinking something like this?

\IPS\Theme::i()->getTemplate('pagination')->template(params...);

Is that possible?

Link to comment
Share on other sites

19 minutes ago, Ilya Hoilik said:

Yes


$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $baseUrl, $totalPages, $currentPage, $limit, TRUE, 'page' );

Great thank you. Could you run me through what each of the params mean so I know what to pass?

$baseUrl, = Just the board url? ->  'http//:mysite.com'

$totalPages = number of pages to to create? -> 10 (integer)

$currentPage, =  I'm not sure what this one wants? An array?

And also the next three I don't know what they are for:

$limit, TRUE, 'page'

Link to comment
Share on other sites

<ips:template parameters="$baseUrl, $pages, $activePage=1, $perPage=25, $ajax=TRUE, $pageParam='page', $simple=false" />
  • $baseUrl is the URL to the current page. You may be able to simply use \IPS\Request::i()->url() depending upon your needs
  • $pages is the total number of pages
  • $activePage is the page you are currently on
  • $perPage is the number of items per page
  • $ajax is a boolean TRUE/FALSE indicating if you want to load subsequent pages via AJAX (which may or may not work if you are using this external to the software's typical use)
  • $pageParam is the GET parameter name to use (defaults to 'page')
  • $simple is a boolean TRUE/FALSE indicating if you want simple pagination, e.g.  "Previous | Next" instead of numbered links
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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