Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: Need help for "advanced" search functionality

  1. #1
    Thread Starter
    Junior Member jaidev's Avatar
    Join Date
    Jan 2010
    Posts
    27
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Need help for "advanced" search functionality

    Hi,

    I am developing a site where we have two main categories:

    For sale, Wanted.

    Each of these has many sub categories, and we need to be able to perform a search on these sub cats respectively.

    Now, when using the default search engine that comes with WP this would be accomplished by passing a comma separated string containing the IDs of the children of the two main categories to the $cat parameter - and have a radio button select in the search form like this:

    Code:
    <input id="btn_selges" type="radio" name="cat" value="<?php echo jai_get_subcat('1'); ?>" checked> <lable>Til salgs</lable>
    <input id="btn_kjopes" type="radio" name="cat" value="<?php echo jai_get_subcat('5'); ?>"> <lable>&Oslash;nskes kj&oslash;pt</lable>
    In functions.php the following function returns the list of subcats:

    Code:
    // jai_get_subcat: returns a comma separated list of sub-categories
    function jai_get_subcat($parent) {		
    	$categories = get_categories('child_of='.$parent);
    	$catlist = '';
    	foreach ($categories as $cat) {
    		$catlist.= $cat->cat_ID.',';
    	}
    	$catlist .= $parent; // in case someone has put an ad in the parent cat
    	return $catlist;
    }
    However, this does not work with the CP-search engine implemented in theme-functions.php. If I comment out the filter/action registration:

    Code:
    // search on custom fields
    // add_filter('posts_join', 'custom_search_join');
    // add_filter('posts_where', 'custom_search_where');
    // add_filter('posts_groupby', 'custom_search_groupby');
    and comment out the check to only display post in $cat if $cat is set in the search.php:

    Code:
    <?php while(have_posts()) : the_post() ?>
    
                        <?php //if (!in_category($cat) && $cat != 0) continue; // only display posts in cat if cat is set ?>
    ... I can get it to work. But now I am not searching the custom fields anymore as this is using the default search engine from WP.

    I would like to know how to change the SQL query in the CP search engine so that it accepts a list of categories IDs to search.

    At present, CP302 can display results for a search in 1 category, but it is not really a search! it is a refine search done in search.php. It still searches through all categories for search string $s, which is not very smart if the system has a lot of categories and a lot of content.

    Thanks for a very good system! It only needs some more advanced search functionality and it will be fantastic! I will need to do this for a client and would give you the code later if you could help me with the SQL stuff described above.

    you can view a test version of the system here, http://jai.no/okofunn/v4/ and it shows that you can really customize the CP theme

    thanks,
    Jaidev
    @ Jai Design

  2. #2
    Veteran tbase's Avatar
    Join Date
    Feb 2010
    Location
    Idaho
    Posts
    2,018
    Thanks
    246
    Thanked 67 Times in 64 Posts

    Re: Need help for "advanced" search functionality

    You must be an AppThemes customer and logged in to view this response. Join today!
    [CENTER]


    TreasureValleyBusiness.com

    [/CENTER]

  3. #3
    Thread Starter
    Junior Member jaidev's Avatar
    Join Date
    Jan 2010
    Posts
    27
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Re: Need help for "advanced" search functionality

    You must be an AppThemes customer and logged in to view this response. Join today!

  4. #4
    isdngirl's Avatar
    Join Date
    Apr 2010
    Posts
    29
    Thanks
    0
    Thanked 6 Times in 2 Posts

    Re: Need help for "advanced" search functionality

    You must be an AppThemes customer and logged in to view this response. Join today!

  5. #5
    Thread Starter
    Junior Member jaidev's Avatar
    Join Date
    Jan 2010
    Posts
    27
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Re: Need help for "advanced" search functionality

    You must be an AppThemes customer and logged in to view this response. Join today!

  6. #6
    Thread Starter
    Junior Member jaidev's Avatar
    Join Date
    Jan 2010
    Posts
    27
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Re: Need help for "advanced" search functionality

    You must be an AppThemes customer and logged in to view this response. Join today!

  7. #7
    Community Partner scarstens's Avatar
    Join Date
    Apr 2010
    Location
    Cave Creek, AZ USA
    Posts
    912
    Thanks
    2
    Thanked 129 Times in 86 Posts

    Re: Need help for "advanced" search functionality

    You must be an AppThemes customer and logged in to view this response. Join today!
    ~ Seth Carstens, Sethmatics Inc.


  8. #8
    Veteran bluecafe's Avatar
    Join Date
    Apr 2010
    Location
    Berlin
    Posts
    1,563
    Thanks
    58
    Thanked 359 Times in 273 Posts

    Re: Need help for "advanced" search functionality

    You must be an AppThemes customer and logged in to view this response. Join today!

  9. #9
    Thread Starter
    Junior Member jaidev's Avatar
    Join Date
    Jan 2010
    Posts
    27
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Re: Need help for "advanced" search functionality

    You must be an AppThemes customer and logged in to view this response. Join today!

  10. #10
    Community Partner scarstens's Avatar
    Join Date
    Apr 2010
    Location
    Cave Creek, AZ USA
    Posts
    912
    Thanks
    2
    Thanked 129 Times in 86 Posts

    Re: Need help for "advanced" search functionality

    You must be an AppThemes customer and logged in to view this response. Join today!
    ~ Seth Carstens, Sethmatics Inc.


Page 1 of 4 123 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need help for "advanced" search functionality
    By Jaidev in forum Help Using ClassiPress
    Replies: 1
    Last Post: December 31st, 1969, 07:00 PM