Skip to content

Commit aa3ab7c

Browse files
[5.2] Usability: Back-end - Add item position and total count to Page Navigation (#43575)
* Add item position and total count to Page Navigation * Update layouts/joomla/pagination/links.php * Update language/en-GB/lib_joomla.ini * Update administrator/language/en-GB/lib_joomla.ini --------- Co-authored-by: Brian Teeman <[email protected]>
1 parent dfb572d commit aa3ab7c

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

administrator/language/en-GB/lib_joomla.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ JLIB_HTML_NO_RECORDS_FOUND="No records found."
454454
JLIB_HTML_PAGE_CURRENT="Page %s"
455455
JLIB_HTML_PAGE_CURRENT_OF_TOTAL="Page %s of %s"
456456
JLIB_HTML_PAGINATION="Pagination"
457+
JLIB_HTML_PAGINATION_NUMBERS="%1$d - %2$d / %3$d items"
457458
JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST="Please first make a selection from the list."
458459
JLIB_HTML_PUBLISH_ITEM="Publish Item"
459460
JLIB_HTML_PUBLISHED_EXPIRED_ITEM="Published, but has Expired."

language/en-GB/lib_joomla.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ JLIB_HTML_NO_RECORDS_FOUND="No records found."
448448
JLIB_HTML_PAGE_CURRENT="Page %s"
449449
JLIB_HTML_PAGE_CURRENT_OF_TOTAL="Page %s of %s"
450450
JLIB_HTML_PAGINATION="Pagination"
451+
JLIB_HTML_PAGINATION_NUMBERS="%1$d - %2$d / %3$d items"
451452
JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST="Please first make a selection from the list."
452453
JLIB_HTML_PUBLISH_ITEM="Publish Item"
453454
JLIB_HTML_PUBLISHED_EXPIRED_ITEM="Published, but has Expired."

layouts/joomla/pagination/links.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616

1717
$list = $displayData['list'];
1818
$pages = $list['pages'];
19+
$total = $list['total'];
1920

2021
$options = new Registry($displayData['options']);
2122

22-
$showLimitBox = $options->get('showLimitBox', false);
23-
$showPagesLinks = $options->get('showPagesLinks', true);
24-
$showLimitStart = $options->get('showLimitStart', true);
23+
$showLimitBox = $options->get('showLimitBox', false);
24+
$showPagesLinks = $options->get('showPagesLinks', true);
25+
$showLimitStart = $options->get('showLimitStart', true);
26+
$showItemPosition = $options->get('showItemPosition', true);
2527

2628
// Calculate to display range of pages
2729
$currentPage = 1;
@@ -43,21 +45,29 @@
4345
$range = ceil($currentPage / $step);
4446
}
4547
}
46-
?>
47-
48+
$first = ($currentPage - 1) * $list['limit'] + 1;
49+
$last = $first + $list['limit'] - 1;
50+
$last = $last > $total ? $total : $last;
4851

49-
<?php if (!empty($pages)) : ?>
52+
?>
53+
<?php if (!empty($pages) || $showItemPosition) : ?>
5054
<nav class="pagination__wrapper" aria-label="<?php echo Text::_('JLIB_HTML_PAGINATION'); ?>">
51-
<div class="pagination pagination-toolbar text-center">
55+
<?php if ($showItemPosition) : ?>
56+
<div class="text-end me-3">
57+
<?php echo Text::sprintf('JLIB_HTML_PAGINATION_NUMBERS', $first, $last, $total); ?>
58+
</div>
59+
<?php endif; ?>
60+
61+
<div class="pagination pagination-toolbar text-center mt-0">
5262

5363
<?php if ($showLimitBox) : ?>
5464
<div class="limit float-end">
5565
<?php echo Text::_('JGLOBAL_DISPLAY_NUM') . $list['limitfield']; ?>
5666
</div>
5767
<?php endif; ?>
5868

59-
<?php if ($showPagesLinks) : ?>
60-
<ul class="pagination ms-auto mb-4 me-0">
69+
<?php if ($showPagesLinks && !empty($pages)) : ?>
70+
<ul class="pagination ms-auto me-0">
6171
<?php echo LayoutHelper::render('joomla.pagination.link', $pages['start']); ?>
6272
<?php echo LayoutHelper::render('joomla.pagination.link', $pages['previous']); ?>
6373
<?php foreach ($pages['pages'] as $k => $page) : ?>

0 commit comments

Comments
 (0)