Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2007
    Posts
    3
    Plugin Contributions
    0

    Default Need search to return items for empty/blank keyword

    I want search to return all items when no keyword is entered (the default behaviour is to return no items).

    I'd like to be able select a category from the drop-down on the advanced search page, not enter a search term, click search and see all the items in that category.

    You can do this manually by entering '%' into the keyword field (it's the mysql wildcard). However if I try to override $_GET['keyword'] to be '%' when it is empty, zen cart redirects to advanced_search instead of advanced_search_result.

    Any suggestions?

  2. #2
    Join Date
    Apr 2006
    Posts
    265
    Plugin Contributions
    0

    Default Re: Need search to return items for empty/blank keyword

    How are you doing the over-ride? If you're doing it properly, ZenCart should not be able to determine a difference between your over-ride and someone typing it in.

    BrandTim

  3. #3
    Join Date
    Aug 2007
    Posts
    3
    Plugin Contributions
    0

    Idea or Suggestion Re: Need search to return items for empty/blank keyword

    Thanks Tim. I'm new to zencart and I'm not sure if I'm doing it correctly.

    In includes/templates/mysite/common/tpl_main_page.php I have:

    PHP Code:
    if( $current_page_base == 'index' && isset($_GET['cat']) )
        require(
    DIR_WS_TEMPLATE "templates/tpl_category.php");
    else if( 
    file_exists(DIR_WS_TEMPLATE "templates/tpl_$current_page_base.php") )
        require(
    DIR_WS_TEMPLATE "templates/tpl_$current_page_base.php");
    else
        require(
    DIR_WS_TEMPLATE "templates/tpl_not_found.php"); 
    My search forms all have
    Code:
    action="index.php?main_page=advanced_search_result"
    but when no keyword is entered in the text field zencart redirects to index.php?main_page=advanced_search.php

    Is this the information you're after?

  4. #4
    Join Date
    Apr 2006
    Posts
    265
    Plugin Contributions
    0

    Default Re: Need search to return items for empty/blank keyword

    Ok ... you totally lost me on what that code is supposed to do.

    If your goal is just to search for '%' when the search field is left blank, I'd think this would be an easier way:

    In includes/modules/pages/advanced_search_result/header_php.php, after this line:

    PHP Code:
    $_GET['keyword'] = trim($_GET['keyword']); 
    add this:

    PHP Code:
    if (empty($_GET['keyword']) || $_GET['keyword']==HEADER_SEARCH_DEFAULT_TEXT || $_GET['keyword'] == KEYWORD_FORMAT_STRING) {$_GET['keyword']='%';} 
    BrandTim

  5. #5
    Join Date
    Aug 2007
    Posts
    3
    Plugin Contributions
    0

    Default Re: Need search to return items for empty/blank keyword

    Thanks! That works perfectly!

    I'm not sure if it's the "correct" way to do it as I'll lose those changes if I update zencart in the future... but I can't see any other way to get the override system to do what I want.

    This is why I don't think it's "correct", if you're interested.
    The override system really simplified

    Thanks again, I appreciate it.

  6. #6
    Join Date
    Dec 2009
    Location
    Sarajevo
    Posts
    80
    Plugin Contributions
    0

    Default Re: Need search to return items for empty/blank keyword

    searching trough forum I found this topic and it helped me a lot because I needed same solution on my site, so thank you!

    Cheers

 

 

Similar Threads

  1. v151 Search - including or ignoring "and" as first keyword in search query
    By nikerymis in forum General Questions
    Replies: 0
    Last Post: 27 Jan 2014, 08:44 PM
  2. v151 need to set price for a few items all other items use weight
    By cubmanky in forum Built-in Shipping and Payment Modules
    Replies: 13
    Last Post: 8 Jan 2014, 09:32 PM
  3. empty cart, return to home page
    By skylab001 in forum General Questions
    Replies: 2
    Last Post: 8 Dec 2011, 02:26 AM
  4. Empty Search Returns Blank Page
    By djdavedawson in forum General Questions
    Replies: 4
    Last Post: 9 Nov 2009, 07:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg