Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Add "first" and "last" to result pages


Duroniel

Recommended Posts

Posted

I have been adding a lot of products to my website, and realized that in some of the sub-categories, I have over 10 pages of stuff. Therefor it would be nice to have a "first" and "last" button/link so that a customer doesn't have to click through all the pages if they know what they are looking for. I would like to have these links to the left and right of the "previous" and "next" ones.

 

I have osc version 2.3.3.

Posted

Have a look at includes/classes/split_page_results.php

 

You should be able to do what you want with two lines of code (one line for each link).

Posted

Have a look at includes/classes/split_page_results.php

 

You should be able to do what you want with two lines of code (one line for each link).

 

Okay, I got both buttons working now, but can you please tell me what it "should" say instead of +25? I tried last_page and max_page_numbers and it didn't work... as I said, this works now, but I am curious of the "clean" answer :)

 

// previous button - not displayed on first page
 if ($this->current_page_number > 1) $display_links_string .= '<a href="' . tep_href_link(basename($PHP_SELF), $parameters . $this->page_name . '=' . ($this->first_page), $request_type) . '" class="pageResults" title=" ' . PREVNEXT_TITLE_FIRST_PAGE . ' "><u>' . PREVNEXT_BUTTON_FIRST . '</u></a>  ';
 if ($this->current_page_number > 1) $display_links_string .= '<a href="' . tep_href_link(basename($PHP_SELF), $parameters . $this->page_name . '=' . ($this->current_page_number - 1), $request_type) . '" class="pageResults" title=" ' . PREVNEXT_TITLE_PREVIOUS_PAGE . ' "><u>' . PREVNEXT_BUTTON_PREV . '</u></a>  ';
// check if number_of_pages > $max_page_links
 $cur_window_num = intval($this->current_page_number / $max_page_links);
 if ($this->current_page_number % $max_page_links) $cur_window_num++;
 $max_window_num = intval($this->number_of_pages / $max_page_links);
 if ($this->number_of_pages % $max_page_links) $max_window_num++;
// previous window of pages
 if ($cur_window_num > 1) $display_links_string .= '<a href="' . tep_href_link(basename($PHP_SELF), $parameters . $this->page_name . '=' . (($cur_window_num - 1) * $max_page_links), $request_type) . '" class="pageResults" title=" ' . sprintf(PREVNEXT_TITLE_PREV_SET_OF_NO_PAGE, $max_page_links) . ' ">...</a>';
// page nn button
 for ($jump_to_page = 1 + (($cur_window_num - 1) * $max_page_links); ($jump_to_page <= ($cur_window_num * $max_page_links)) && ($jump_to_page <= $this->number_of_pages); $jump_to_page++) {
 if ($jump_to_page == $this->current_page_number) {
	 $display_links_string .= ' <strong>' . $jump_to_page . '</strong> ';
 } else {
	 $display_links_string .= ' <a href="' . tep_href_link(basename($PHP_SELF), $parameters . $this->page_name . '=' . $jump_to_page, $request_type) . '" class="pageResults" title=" ' . sprintf(PREVNEXT_TITLE_PAGE_NO, $jump_to_page) . ' "><u>' . $jump_to_page . '</u></a> ';
 }
 }
// next window of pages
 if ($cur_window_num < $max_window_num) $display_links_string .= '<a href="' . tep_href_link(basename($PHP_SELF), $parameters . $this->page_name . '=' . (($cur_window_num) * $max_page_links + 1), $request_type) . '" class="pageResults" title=" ' . sprintf(PREVNEXT_TITLE_NEXT_SET_OF_NO_PAGE, $max_page_links) . ' ">...</a> ';
// next button
 if (($this->current_page_number < $this->number_of_pages) && ($this->number_of_pages != 1)) $display_links_string .= ' <a href="' . tep_href_link(basename($PHP_SELF), $parameters . 'page=' . ($this->current_page_number + 1), $request_type) . '" class="pageResults" title=" ' . PREVNEXT_TITLE_NEXT_PAGE . ' "><u>' . PREVNEXT_BUTTON_NEXT . '</u></a> ';
 if (($this->current_page_number < $this->number_of_pages) && ($this->number_of_pages != 1)) $display_links_string .= ' <a href="' . tep_href_link(basename($PHP_SELF), $parameters . 'page=' . ($this->current_page_number + 25), $request_type) . '" class="pageResults" title=" ' . PREVNEXT_TITLE_LAST_PAGE . ' "><u>' . PREVNEXT_BUTTON_LAST . '</u></a> ';
 return $display_links_string;
}

 

Oh, nevermind! I think I got it, I replaced it with number_of_pages :)

Posted

Thank you for pointing me to the right direction! I have no experience in coding, let alone PHP so I had no idea where to start :P

Posted

Most people including some long-standing regulars would have complained that I did not give the code.

 

I say to you well done for coding this up, now you are wrong when you say "I have no experience in coding". In fact now you do have some experience in code :)

Posted

:D Thanks!

 

Well, I have been fiddling with some code for different things since I started with OSC, but I am in no way a programmer of any kind, so it's very much trial and error :P

Archived

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

×
×
  • Create New...