Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using jquery simple pagination #157

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion productcomments.php
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,6 @@ public function hookDisplayHeader()
if ($this->context->controller instanceof ProductControllerCore) {
$jsList[] = '/modules/productcomments/views/js/post-comment.js';
$jsList[] = '/modules/productcomments/views/js/list-comments.js';
$jsList[] = '/modules/productcomments/views/js/jquery.simplePagination.js';
}
foreach ($cssList as $cssUrl) {
$this->context->controller->registerStylesheet(sha1($cssUrl), $cssUrl, ['media' => 'all', 'priority' => 80]);
Expand Down Expand Up @@ -969,6 +968,23 @@ private function renderProductCommentsList($product)
$commentsNb = $productCommentRepository->getCommentsNumber($product->id, (bool) Configuration::get('PRODUCT_COMMENTS_MODERATE'));
$isPostAllowed = $productCommentRepository->isPostAllowed($product->id, (int) $this->context->cookie->id_customer, (int) $this->context->cookie->id_guest);

/* generate pagination */
$commentsNav = '';
$commentsTotalPages = 0;
$commentsPerPage = (int) Configuration::get('PRODUCT_COMMENTS_COMMENTS_PER_PAGE');
if ($commentsNb > 0) {
$commentsTotalPages = ceil($commentsNb / $commentsPerPage);
$commentsNav .= '<ul>';
$prevCount = 0;
$commentsNav .= '<li data-page="' . $prevCount . '" id="pcl_page_' . $prevCount . '"><span class="prev"><i class="material-icons">chevron_left</i></span></li>';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it would be better to have a dedicated template for $commentsNav rather than writing serious HTML in PHP?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. This pure HTML is moved to TPL.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

for ($pageCount = 1; $pageCount <= $commentsTotalPages; ++$pageCount) {
$commentsNav .= '<li data-page="' . $pageCount . '" id="pcl_page_' . $pageCount . '"><span>' . $pageCount . '</span></li>';
}
$nextCount = $commentsTotalPages + 1;
$commentsNav .= '<li data-page="' . $nextCount . '" id="pcl_page_' . $nextCount . '"><span class="next"><i class="material-icons">chevron_right</i></span></li>';
$commentsNav .= '</ul>';
}

$this->context->smarty->assign([
'post_allowed' => $isPostAllowed,
'usefulness_enabled' => Configuration::get('PRODUCT_COMMENTS_USEFULNESS'),
Expand All @@ -987,6 +1003,8 @@ private function renderProductCommentsList($product)
'productcomments',
'ReportComment'
),
'nav_comments' => $commentsNav,
'list_total_pages' => $commentsTotalPages,
]);

return $this->context->smarty->fetch('module:productcomments/views/templates/hook/product-comments-list.tpl');
Expand Down
10 changes: 7 additions & 3 deletions views/css/productcomments.css
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@
font-size: 13px;
}

@media (min-width: 768px) {
@media (min-width: 960px) {
#product-comments-list-footer {
position: relative;
min-height: 45px;
Expand All @@ -607,7 +607,7 @@
}
}

@media (max-width: 768px) {
@media (max-width: 960px) {
#product-comments-list-footer {
display: flex;
flex-direction: row-reverse;
Expand All @@ -616,7 +616,7 @@
}
}

@media (max-width: 576px) {
@media (max-width: 768px) {
#product-comments-list-footer {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -665,3 +665,7 @@
#product-comments-list-pagination ul li.active span {
cursor: not-allowed;
}

#product-comments-list-pagination ul li.hidden {
display: none;
}
Loading