Skip to:
Content

bbPress.org

Changeset 2440 for trunk/search.php


Ignore:
Timestamp:
06/04/2010 09:10:20 PM (15 years ago)
Author:
chrishajer
Message:

Trying again to fix pagination in search. Fixes #1274. Props GautamGupta

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/search.php

    r2436 r2440  
    1111    global $page;
    1212    if ( !$page ) $page = 1;
    13     $search_start = 5 * ( $page - 1);
    14     $search_stop = 5;
     13    $per_page = ceil( (int) bb_get_option( 'page_topics' ) / 2 );
     14    $search_start = $per_page * ( $page - 1 );
     15    $search_stop = $per_page;
    1516   
    1617    /* Recent */
    1718    add_filter( 'bb_recent_search_fields',   create_function( '$f', 'return $f . ", MAX(post_time) AS post_time";' ) );
    1819    add_filter( 'bb_recent_search_group_by', create_function( '', 'return "t.topic_id";' ) );
    19     $bb_query_form->BB_Query_Form( 'post', array(), array( 'order_by' => 'p.post_time', 'page' => 1, 'post_status' => 0, 'topic_status' => 0, 'post_text' => $q, 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_recent_search' );
     20    $bb_query_form->BB_Query_Form( 'post', array(), array( 'order_by' => 'p.post_time', 'page' => 1, 'per_page' => -1, 'post_status' => 0, 'topic_status' => 0, 'post_text' => $q, 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_recent_search' );
    2021    $recent = $bb_query_form->results;
    2122    if ( $recent ) {
     
    2728   
    2829    /* Relevant */
    29     $bb_query_form->BB_Query_Form( 'topic', array( 'search' => $q ), array( 'page' => 1, 'post_status' => 0, 'topic_status' => 0, 'search', 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_relevant_search' );
     30    $bb_query_form->BB_Query_Form( 'topic', array( 'search' => $q ), array( 'page' => 1, 'post_status' => 0, 'per_page' => -1, 'topic_status' => 0, 'search', 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_relevant_search' );
    3031    $relevant = $bb_query_form->results;
    31     if ( $recent ) {
     32    if ( $relevant ) {
    3233        $relevant_count = isset( $bb_query_form->count ) ? $bb_query_form->count : count( $relevant );
    3334        $relevant = array_slice( $relevant, $search_start, $search_stop );
     
    5556endif;
    5657
    57 bb_load_template( 'search.php', array( 'q', 'recent', 'relevant', 'page', 'search_count' ), $q );
     58bb_load_template( 'search.php', array( 'q', 'recent', 'relevant', 'page', 'per_page', 'search_count' ), $q );
    5859
    5960?>
Note: See TracChangeset for help on using the changeset viewer.