Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Removing the pagination if only 1 page of products?


vampirehunter

Recommended Posts

post your product_listing code here so we can see what you have ...

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

hi

basically ive got this for the main bit which ive changed. the only thing ive changed is put the pagination in div tags.

 

<?php
/*
 $Id$
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2010 osCommerce
 Released under the GNU General Public License
*/

 $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');
?>
 <div class="contentText">
<?php
 if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
  <div class="nav-pages">

  <div class="pp">
  <ul><li class="viewnav"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></li></ul>

  </div>

  <div class="pp-results">
  <?php
  echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y')));
  ?>
  </div>

</div>
<?php
 }

 $prod_list_contents = '<div class="ui-widget infoBoxContainer">' .
					'  <div class="ui-widget-header ui-corner-top infoBoxHeading">' .
					'	<table border="0" width="100%" cellspacing="0" cellpadding="2" class="productListingHeader">' .
					'	  <tr>';

 

basically i want to add something here next to this code.

 

so that if there is only 1 page of results showing, then it won't show Page "1" like it is doing now. if there is more than 1 page of results, then it shows page 1,2,3 , Next etc.

 

i just want to remove the "1" if there is only one page of results.

 

  <div class="pp-results">
  <?php
  echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y')));
  ?>
  </div>

 

Ive been trying various "if else" statements for the above code, but can't seem to get it to work.

 

Unless i have to do something in the splitpage results page code?

Link to comment
Share on other sites

well having woke up today having dreamt all last night (yes i know, quite sad) thinking how to resolve this

 

i came up with this just now

 

<div class="pp-results">

  <?php

  if ($listing_split->number_of_rows <= MAX_DISPLAY_SEARCH_RESULTS) {
  echo 'test';
  }

  else {
  echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y')));
  }
  ?>
  </div>

 

Do you think my "if" statement above is coded correctly?

i've put an echo "test" to check if its working, but i will leave an empty echo for the final version as im simply trying to remove the page "1" from showing if there are only 1 page of results to be shown.

 

 

 

If my statement is right, im checking if the results are less than the maximum ive set in admin.

 

If they are less than my maximum (1 page of results), then it will show my echo statement,

else if results are over the maximum ive set, then the pagination will kick in and links will show.

 

ive just tested it via the admins maximum values, and it seems to be working (i think). My current maximum value is 10.

 

 

So i reckon its working. if you have any advice on that "if" statement, feel free to share, if its even valid or i should be doing it another way?

 

thanks

Link to comment
Share on other sites

looks good to me, but I think you could use the max_display_results constant in place of the > 0 that is currently used in the initial if,

if would make your code shorter and easier to read

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

looks good to me, but I think you could use the max_display_results constant in place of the > 0 that is currently used in the initial if,

if would make your code shorter and easier to read

 

sorry im confused, do you mean the first code right at the top?

 

this bit here? this is the default code as it is. i haven't touched this bit.

<?php
/*
 $Id$
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2010 osCommerce
 Released under the GNU General Public License
*/
 $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');
?>
 <div class="contentText">
<?php
 if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>

 

 

i only added in this line here below.

 

if ($listing_split->number_of_rows <= MAX_DISPLAY_SEARCH_RESULTS) {
	  echo 'test';
	  }

Link to comment
Share on other sites

yes

 

so that it becomes

 

$listing_split->number_of_rows > MAX_DISPLAY_SEARCH_RESULTS

 

you only need pagination if you have more than 1 page of results, it is just more logical

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...