Jump to content

Archived

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

montyrach

Changing "Result Pages" format (1 of #ofpages instead of 1, 2, 3, 4 etc)

Recommended Posts

I'm made my shop into a responsive bootstrap format. I'm looking to make my "Result Pages" format into a simpler navigation format.

 

Instead of the current format for result pages

 

Result Pages:  1  2  3  4  5 ...  [Next >>]

 

I want to show simply

 

[<<Prev] 1 of  6 [Next >>]

 

Of course my Prev and Next will be made into pretty bootstrap buttons  ;)

 

So, how can I modify

$listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y')))

to split out my html the way I want?


Rachel M.

Share this post


Link to post
Share on other sites

This would be done in the split_page_results.php class file

 

/includes/classes/split_page_results.php


Help shape the future of Phoenix; join the Phoenix Club

Share this post


Link to post
Share on other sites

Thanks for that! Here's my final code in case it would help anyone :thumbsup:

    function display_links($max_page_links, $parameters = '') {
      global $PHP_SELF, $request_type;

      $display_links_string = '';

      if (tep_not_null($parameters) && (substr($parameters, -1) != '&')) $parameters .= '&';

// previous button - disabled on first page
      if ($this->current_page_number > 1) { $display_links_string .= '<ul class="pager"><li><a href="' . tep_href_link(basename($PHP_SELF), $parameters . $this->page_name . '=' . ($this->current_page_number - 1), $request_type) . '" title=" ' . PREVNEXT_TITLE_PREVIOUS_PAGE . ' "><span class="glyphicon glyphicon-chevron-left"></span></a></li>  '; } else { $display_links_string .= '<ul class="pager"><li class="disabled"><a><span class="glyphicon glyphicon-chevron-left"></span></a></li>  '; }

// 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++;

// Which page are we on of how many pages?
      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 .= ' Page <strong>' . $jump_to_page . '</strong> of ' . $this->number_of_pages;
        } 
      }

// next button, disabled on last page
      if (($this->current_page_number < $this->number_of_pages) && ($this->number_of_pages != 1)) { $display_links_string .= '  <li><a href="' . tep_href_link(basename($PHP_SELF), $parameters . 'page=' . ($this->current_page_number + 1), $request_type) . '" title=" ' . PREVNEXT_TITLE_NEXT_PAGE . ' "><span class="glyphicon glyphicon-chevron-right"></span></a></li></ul>'; } else { $display_links_string .= '  <li class="disabled"><a><span class="glyphicon glyphicon-chevron-right"></span></a></li></ul>'; }

// Only one page ie "1 of 1"
      if ($this->number_of_pages == 1) $display_links_string .= 'of ' . $this->number_of_pages;
      return $display_links_string;
    }

Rachel M.

Share this post


Link to post
Share on other sites

It does look quite neat and organized to show something like < Page 3 of 11 >. However, I would advise you to provide a means of jumping directly to an arbitrary page, rather than forcing a shopper to click a forward or backwards button repeatedly! Some sites make the current page number a text input field (often with a "Go to" button) < Page [ 3 ] of 11 > [Go to], and some make it a drop-down selection list < Page [ 3 |V] of 11 >. For a text input field, obviously you need to validate the input as an integer between 1 and LastPage. For a select, use Javascript to autosubmit the clicked entry.

Share this post


Link to post
Share on other sites

×