Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Reviews pagination using jQuery


PupStar

Recommended Posts

Afternoon guys,

 

I am struggling with this little problem and its really starting to bug me now.

 

I am using the following code to display reviews in a tab on my product_info page

 

<?php
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_REVIEWS);
$reviews_query_raw = "select r.reviews_id, left(rd.reviews_text, 200) as reviews_text, r.reviews_rating, r.date_added, r.customers_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . (int)$product_info['products_id'] . "' and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' and r.reviews_status = 1 and r.approved = '1' order by r.reviews_id desc";
$reviews_split = new splitPageResults($reviews_query_raw, '3');
if ($reviews_split->number_of_rows > 2) {
$reviews_query = tep_db_query($reviews_split->sql_query);
while ($reviews = tep_db_fetch_array($reviews_query)) {
?>
 <div style="padding:4px;"></div>
 <div style="padding:2px;">
	 <?php echo tep_date_long($reviews['date_added']); ?>
 </div>
 <div style="padding:2px;">
	 <strong><?php echo tep_output_string_protected($reviews['customers_name']) . '</strong>  ' . TEXT_STARS_RATING . tep_image(DIR_WS_IMAGES . 'stars_' . $reviews['reviews_rating'] . '.png', sprintf(TEXT_OF_5_STARS, $reviews['reviews_rating'])); ?>
 </div>
 <div style="padding:2px; font-style: italic;">
	 <?php echo tep_output_string_protected($reviews['reviews_text']);?>
 </div>
 <div class="line-separator"></div>
<?php
}
} else {
?>
<div>
 <br /><?php echo TEXT_NO_REVIEWS; ?>
</div>
<div>
 <?php echo TEXT_REVIEW_BUTTON . ' ' . tep_draw_button(IMAGE_BUTTON_WRITE_REVIEW, 'comment', tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, tep_get_all_get_params()), 'primary'); ?>
</div>
<?php
}
if ($reviews_split->number_of_rows > 2) {
?>
<br />
<div class="contentText" style="position:absolute; top:660px; right:410px;">
<?php echo $reviews_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info'))); ?>
</div>
<br /><br />
<div class="buttonSet" style="float: right;">
<span class="buttonAction"><?php echo TEXT_REVIEW_BUTTON . ' ' . tep_draw_button(IMAGE_BUTTON_WRITE_REVIEW, 'comment', tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, tep_get_all_get_params()), 'primary'); ?></span>
</div>
<?php
}
?>
</div>
</div>

 

The issue I have is that when I click 'page 2' of the reviews it reloads the page with the second page of reviews but does not show the previous page link. Also when the page reloads it defaults back to the first tab.

 

Ideally I would like to stop the page reload and load the reviews using jQuery. Is this possible and does anyone have a nice bit of script that would do the job???

 

Thanks for the help

 

Mark

Link to comment
Share on other sites

@@PupStar

 

You could definitely use jQuery to do this without a page reload. I would look at the $.get() method and use it to replace the content of that tab panel on the fly. If that doesn't suit you, you can can also tell jQuery UI which tab to show by default. So then you could check for the $_GET value and load an if else with your PHP to determine which tab to have showing by default.

Matt

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...