Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Jun 2014
    Location
    United States
    Posts
    59
    Plugin Contributions
    0

    Default Search based on category you are in

    Lets say I have multiple products for different categories, I was thinking this would be cool to have it so when you search for something it looks only in the category you are in or if you are not in a category it will make you select the category you wan't to search in.

  2. #2
    Join Date
    Apr 2014
    Posts
    154
    Plugin Contributions
    0

    Default Re: Search based on category you are in

    Quote Originally Posted by StoreOwner View Post
    Lets say I have multiple products for different categories, I was thinking this would be cool to have it so when you search for something it looks only in the category you are in or if you are not in a category it will make you select the category you wan't to search in.
    Have you ever considered test driving your site to see what functional capabilities zencart has? I say this as the advanced search already HAS this function to filter out categories and subcategories.

    But if you are speaking not using the advanced search and just the search box, then sure you could implement the search box to limit the results to the current category. However, is this really neccesary from a customer standpoint? I would not go this route but instead include a mod like dynamic filter as it has sorting capabilities on that is dependent on the category you are in to show the selections.

  3. #3
    Join Date
    Jun 2014
    Location
    United States
    Posts
    59
    Plugin Contributions
    0

    Default Re: Search based on category you are in

    Quote Originally Posted by yaritai View Post
    Have you ever considered test driving your site to see what functional capabilities zencart has? I say this as the advanced search already HAS this function to filter out categories and subcategories.

    But if you are speaking not using the advanced search and just the search box, then sure you could implement the search box to limit the results to the current category. However, is this really neccesary from a customer standpoint? I would not go this route but instead include a mod like dynamic filter as it has sorting capabilities on that is dependent on the category you are in to show the selections.
    I would like it because for a shop like mine it would slim things down for customers, instead of having to search nonstop + see what products I have it would make things way easier..

    Searching is used very often in my store..

  4. #4
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,744
    Plugin Contributions
    22

    Default Re: Search based on category you are in

    I definitely agree with yaritai that this is not an option I'd like seeing - advanced search already has an option to search in specific category. The results might come out confusing, or even worse, you might not get the results that might lead to a sale...

    But, it's your site and you decide if you want to have it. I'll assume you want this for your header search box. Unless it was previously customized or replaced with another mod, you could try the following:
    includes/templates/YOUR_TEMPLATE/sideboxes/tpl_search_header.php
    Find:
    Code:
    $content .= zen_draw_hidden_field('search_in_description', '1') . zen_hide_session_id();
    and replace with:
    Code:
    // BOF search in current category only
      $content .= zen_draw_hidden_field('search_in_description', '1');
      if($current_category_id) {
    	  $content .= zen_draw_hidden_field('categories_id', $current_category_id);
    	  $content .= zen_draw_hidden_field('inc_subcat', '1');
      }
      $content .=  zen_hide_session_id();
      // EOF search in current category only
    Please note that I advise against doing this, but I don't know your specific requirements nor your site and products so this might actually be a good idea in some specific cases.

    Regards,
    Leonard

  5. #5
    Join Date
    Jun 2014
    Location
    United States
    Posts
    59
    Plugin Contributions
    0

    Default Re: Search based on category you are in

    Quote Originally Posted by balihr View Post
    I definitely agree with yaritai that this is not an option I'd like seeing - advanced search already has an option to search in specific category. The results might come out confusing, or even worse, you might not get the results that might lead to a sale...

    But, it's your site and you decide if you want to have it. I'll assume you want this for your header search box. Unless it was previously customized or replaced with another mod, you could try the following:
    includes/templates/YOUR_TEMPLATE/sideboxes/tpl_search_header.php
    Find:
    Code:
    $content .= zen_draw_hidden_field('search_in_description', '1') . zen_hide_session_id();
    and replace with:
    Code:
    // BOF search in current category only
      $content .= zen_draw_hidden_field('search_in_description', '1');
      if($current_category_id) {
    	  $content .= zen_draw_hidden_field('categories_id', $current_category_id);
    	  $content .= zen_draw_hidden_field('inc_subcat', '1');
      }
      $content .=  zen_hide_session_id();
      // EOF search in current category only
    Please note that I advise against doing this, but I don't know your specific requirements nor your site and products so this might actually be a good idea in some specific cases.

    Regards,
    Leonard
    Thanks again Leonard, one more thing and I think my store looks complete

    Can I add a search bar in product listing page above product image product name price and centered?

    or is this a pain to do?

  6. #6
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,744
    Plugin Contributions
    22

    Default Re: Search based on category you are in

    Quote Originally Posted by StoreOwner View Post
    Can I add a search bar in product listing page above product image product name price and centered?
    To be perfectly honest - I have no idea. I've never had any similar requests...

    You might give this a try, although I have no idea if it'll work:
    edit your includes/templates/YOUR_TEMPLATE/template/tpl_index_categories.php, add a new div above the pagination and then require tpl_search_header.php (which you'll need to modify a bit to echo the $content so it would be best to duplicate the file and rename it). You would do the same for tpl_index_product_list.php. Oh, and you'll need to exclude the code based on $current_page_base because, for example, advanced_search_results uses tpl_index_product_list.php for the results...

    This is just an idea which I haven't tested, although I don't see a reason why it wouldn't work. Unfortunately, I don't have the time to go play with it right now, sorry.

  7. #7
    Join Date
    Jun 2014
    Location
    United States
    Posts
    59
    Plugin Contributions
    0

    Default Re: Search based on category you are in

    Alright thx again, I will just leave it for now maybe mess with it later :)

  8. #8
    Join Date
    Jun 2014
    Location
    United States
    Posts
    59
    Plugin Contributions
    0

    Default Re: Search based on category you are in

    Alright so I started messing with it again and It doesn't seem to work right, just displays the code in the categories

    at the top of tpl_index_categories.php I add this

    <div class="searchListing" id="indexCategories">
    require($template->get_template_dir('tpl_search_header.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_search_header.php');
    }

  9. #9
    Join Date
    Jun 2014
    Location
    United States
    Posts
    59
    Plugin Contributions
    0

    Default Re: Search based on category you are in

    Bumpity bump bump

  10. #10
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,744
    Plugin Contributions
    22

    Default Re: Search based on category you are in

    Quote Originally Posted by StoreOwner View Post
    Alright so I started messing with it again and It doesn't seem to work right, just displays the code in the categories

    at the top of tpl_index_categories.php I add this

    <div class="searchListing" id="indexCategories">
    require($template->get_template_dir('tpl_search_header.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_search_header.php');
    }
    If this is the EXACT code you added, then of course it's not working - you need to wrap the php code inside php tags... Something like this:
    Code:
    <div id="categorySearch">
    <?php require($template->get_template_dir('tpl_search_header.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_search_header.php'); ?>
    </div>
    Keep in mind this WON'T work unless you modify the tpl_search_header.php file as well and echo the content, but if you do that in the same file, you'll mess it up for the header... The best solution would be to create a clone of the header search box and then use that for listing pages, but you could always use the hillbilly method like this:
    Code:
    <div id="categorySearch">
    <?php require($template->get_template_dir('tpl_search_header.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_search_header.php');
    echo $content; ?>
    </div>
    Just don't tell anyone you heard this from me...

    Regards,
    L.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Whoops! Sorry, but you are not allowed to perform the action requested. You are still
    By buildingblocks in forum All Other Contributions/Addons
    Replies: 14
    Last Post: 5 Nov 2012, 09:52 PM
  2. Replies: 2
    Last Post: 1 Mar 2011, 11:15 PM
  3. Pay tax based on the zip code you are from?
    By CindyM22 in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 2
    Last Post: 13 Jul 2009, 09:32 PM
  4. Can you change the layout colors based on category??
    By Yzerman19 in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 17 May 2009, 04:15 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