acidvertigo Posted July 20, 2012 Share Posted July 20, 2012 Hello i'm triyng to implement the pagination header tag rel=next" and rel="prev" for paginated content as product_new.php and manufacrturer_id. I'm using this code: if (isset($_GET['page']) && ($_GET['page'] > 1)) { $display_previous_page = '<link rel="prev" href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . $page . 'page=' . ($_GET['page'] - 1), $request_type) . '" />'; $display_next_page = '<link rel="next" href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . $page . 'page=' . ($_GET['page'] + 1), $request_type) . '" />'; echo $display_previous_page; echo $display_next_page; } but on the first page does not show the rel="next" header on the first page (only starts from page=2). There is a better way to have correct prev, next chain starting from the first page of the results? Link to comment Share on other sites More sharing options...
Harald Ponce de Leon Posted July 20, 2012 Share Posted July 20, 2012 HI Luca.. It's not displaying because you have: ($_GET['page'] > 1) which won't show on the first page. Something like the following is a good start: if (isset($_GET['page']) && ($_GET['page'] > 1)) { $display_previous_page = '<link rel="prev" href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . $page . 'page=' . ($_GET['page'] - 1), $request_type) . '" />'; echo $display_previous_page; } $display_next_page = '<link rel="next" href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . $page . 'page=' . ($_GET['page'] + 1), $request_type) . '" />'; echo $display_next_page; Kind regards, , osCommerce Link to comment Share on other sites More sharing options...
acidvertigo Posted July 21, 2012 Author Share Posted July 21, 2012 Thank you @@harald i've modified the code as follows and it works: if (isset($_GET['page']) && ($_GET['page'] > 1)) { $display_previous_page = '<link rel="prev" href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . $page . 'page=' . ($_GET['page'] - 1), $request_type) . '" />'; echo $display_previous_page; } $file = $_SERVER["SCRIPT_NAME"]; if (($file = "products_new.php") || ($_GET['page'] > 1)) { $display_next_page = '<link rel="next" href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . $page . 'page=' . ($_GET['page'] + 1), $request_type) . '" />'; echo $display_next_page; } Link to comment Share on other sites More sharing options...
acidvertigo Posted July 21, 2012 Author Share Posted July 21, 2012 Hello @@Harald Ponce de Leon it is possible to call in template top a new class function in split_page_results like this: // display rel="next" and rel="prev" links function display_next_prev_links($max_page_links, $parameters = '') { global $request_type; $display_next_prev_links_string = ''; if (tep_not_null($parameters) && (substr($parameters, -1) != '&')) $parameters .= '&'; // rel="prev" link - not displayed on first page if ($this->current_page_number > 1) $display_next_prev_links_string .= '<link rel="prev" href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . $this->page_name . '=' . ($this->current_page_number - 1), $request_type) . '">'; // check if number_of_pages > $max_page_links $cur_window_num = (int)($this->current_page_number / $max_page_links); if ($this->current_page_number % $max_page_links) $cur_window_num++; $max_window_num = (int)($this->number_of_pages / $max_page_links); if ($this->number_of_pages % $max_page_links) $max_window_num++; // rel="next" link if (($this->current_page_number < $this->number_of_pages) && ($this->number_of_pages != 1)) $display_next_prev_links_string .= '<link rel="next" href="' . tep_href_link(basename($_SERVER['PHP_SELF']), $parameters . 'page=' . ($this->current_page_number + 1), $request_type) . '" class="pageResults" title=" ' . PREVNEXT_TITLE_NEXT_PAGE . ' "><u>' . PREVNEXT_BUTTON_NEXT . '</u></a> '; return $display_next_prev_links_string; } In other words to make split_page_results make the calculation also for the next prev attribute and then display it in template top? Link to comment Share on other sites More sharing options...
acidvertigo Posted July 21, 2012 Author Share Posted July 21, 2012 I put the following code in product new to call the above function $relnextprev = $products_new_split->display_next_prev_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); if ( ! tep_session_is_registered('relnextprev') ) { tep_session_register('relnextprev'); } Then in template top I can echo relnextprev variable and it works. Thank you @@Harald Ponce de Leon for the tip Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.