Page 2 of 6 FirstFirst 1234 ... LastLast
Results 11 to 20 of 52
  1. #11
    Join Date
    May 2009
    Posts
    63
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    sure - what did you do til now?
    The main two files to edit are theses two
    /include/modules/pages/advanced_search_results/header_php.php
    /include/modules/pages/advanced_search/header_php.php

    and of course the template for the search site...

    i think in this thread there is all the information you need, but not nicely structured - so if you post your changes to the 2 files above i`ll have a look at it!
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

  2. #12
    Join Date
    Jul 2009
    Posts
    5
    Plugin Contributions
    0

    xhtml problem Re: Advanced Search - customized product fields?

    Hi Zvenson,

    Thanks for the quick answer.

    Actually I'm stucked, I understand that the answer I was looking for is in this thread but I can't extract it (as you said, you write during the process, so is not linear). Consider also that usually I work with xhtml, css and wordpress, so I'm not good in php.

    Your case is different from mine because you have to search in new tables with new fields, while in my case I've to search in a new field (products_author) of an existing table (products).

    It's not yet useful sending u my code because after some wrong attempts I bring back the code to the original.

    If you have the time and the patience to show me how to procede, I'll be very grateful.

  3. #13
    Join Date
    May 2009
    Posts
    63
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    I can't extract it (as you said, you write during the process, so is not linear).
    - sorry for that - but unfortunately this forum only allows edits 7 minutes after posting :) - and it`s not a tutorial ...


    while in my case I've to search in a new field (products_author) of an existing table (products).
    Is this just a simple text input field where you type in some name and it looks this up in the database?


    First you have to add a field to the advanced search form. Edit:

    /includes/templates/YOUR-TEMPLATE/templates/tpl_advanced_search_default.php file

    and add something like this:
    Code:
      <div class="centeredContent"><?php echo zen_draw_input_field('YOUR_NEW_FIELD', $sData['your_new_field'], 'onfocus="RemoveFormatString(this, \'' . KEYWORD_FORMAT_STRING . '\')"'); ?>
    where you want the new field to appear in the search form.

    Then edit the
    /include/modules/pages/advanced_search/header_php.php

    to "GET" the data from the field by adding something like this:
    Code:
      $your_new_field =      (isset($_GET['your_new_field'])   ? zen_output_string($_GET['your_new_field']) : '');
    now you just (okay, this is the tricky part) need to tell zen-cart to search the new data when something is submitted:
    edit:
    /include/modules/pages/advanced_search_results/header_php.php
    Code:
    (look for similar looking lines to paste this somewhere in between)
    (isset($_GET['your_new_field']) && !is_string($_GET['your_new_field'])) &&
    
    (same thing here: look for similar lines and just paste:
      if (isset($_GET['your_new_field'])) {
        $your_new_field = $_GET['your_new_field'];
      }
    
    (now search for "if (empty($dfrom)" and add somewhere between the &&empty something like this:)
    && empty($your_new_field)
    
    (search for similar and past:)
    case 'YOUR_NEW_FIELD':
        $select_column_list .= 'p.your_fieldname_in_db';
        break;
    
    (search for similar lines and paste:)
    if (isset($_GET['your_new_field']) && zen_not_null($_GET['your_new_field'])) {
      $where_str .= " AND p.your_new_fielname_inDB = :yourfieldnameID";
      $where_str = $db->bindVars($where_str, ':yourfieldnameID', $_GET['your_field_name'], 'string');
    }
    of course you have to change your_field_name to the variable you want to search and change your_new_fildname_inDB as well.


    well this should be it - but i`m totally not sure - im the trial and error kind as well :) just try it and tell me when you succeed - hope it helps somehow...
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

  4. #14
    Join Date
    Jul 2009
    Posts
    5
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    Thanks for the detailed answer!
    I've done the process but it doesn't work yet...

    /tpl_advanced_search_default.php file

    1) Ok, I've added:
    Code:
    <div class="centeredContent"><?php echo zen_draw_input_field('PRODUCTS_AUTHOR', $sData['products_author'], 'onfocus="RemoveFormatString(this, \'' . KEYWORD_FORMAT_STRING . '\')"'); ?>

    /include/modules/pages/advanced_search/header_php.php

    2) Ok, I've added:
    Code:
     $sData['products_author'] = (isset($_GET['products_author'])   ? zen_output_string($_GET['products_author']) : '');

    /include/modules/pages/advanced_search_results/header_php.php

    3) added:
    Code:
    (isset($_GET['products_author']) && !is_string($_GET['products_author'])) &&
    4) added
    Code:
    if (isset($_GET['products_author'])) {
        $your_new_field = $_GET['products_author'];
      }
    5) added
    Code:
    && empty($products_author)
    6) added
    Code:
    case 'PRODUCT_LIST_AUTHOR':
        $select_column_list .= 'p.products_author';
        break;
    7) added, but I'm not sure about the ID part...
    Code:
    if (isset($_GET['products_author']) && zen_not_null($_GET['products_author'])) {
      $where_str .= " AND p.products_author = :productsauthorID";
      $where_str = $db->bindVars($where_str, ':productsauthorID', $_GET['products_author'], 'string');
    }
    Where I'm wrong?

  5. #15
    Join Date
    May 2009
    Posts
    63
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    would be nice if you would tell us what happens when you start the search. This would make things much easier - maybe you can .provide a link
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

  6. #16
    Join Date
    Jul 2009
    Posts
    5
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    Actually I'm testing locally, I haven't put it on the web yet. As soon as I put it I'll tell you.

    Thanks,
    Marco

  7. #17
    Join Date
    May 2009
    Posts
    63
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    well - you can tell us what the error message is - or what happens when you search - "it doesn`t work" is in most cases not helpful at all - but it`s not aleways necessary to upload the site to the web...

    :)
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

  8. #18
    Join Date
    Jul 2009
    Posts
    5
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    Sorry Zvenson,

    you are right. That's the situation in advanced search:

    - if I leave the search field "keywords" blank and i fill only the new search field with an author name (it is supposed to search in my new field "author"), zen cart tell me "You must fill at least one field of research"

    - if i fill "keywords" with a word and the new field with an author name, zencart gives me back only the products that match the first criteria

    So, Zenky seems to ignore my second search field...

  9. #19
    Join Date
    May 2009
    Posts
    63
    Plugin Contributions
    0

    Default Re: Advanced Search - customized product fields?

    Hi Marco!
    Well, my first thought is, that there must be something wrong in this line where you put this:
    && empty($products_author)
    this line should check if the author (or any other field) is empty and if so - you get the error message that nothing has been entered. Well - the reason for this could be, that the "$products_author" variable is empty - try inserting an
    Code:
    echo $products_author;
    above the line where all the "&& emptys" are - then enter a search word in the products author field - do a search and look if the $produts_author is "echoed" (printed) somewhere on your screen. if it is not - then there must be something wrong bevor the actuall search is done...
    Hope this again helps a little!
    www.acousticsdb.com - soundproofing and room acoustics matters | webdesign hamburg

  10. #20
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,360
    Plugin Contributions
    23

    Default Re: Advanced Search - customized product fields?

    I'm now following this thread for my own reasons! I have added a new table of product details (e) instead of adding to the product table. All of possible search fields are boolean - either 1 or 0 which is served by checkboxes on the search form.

    So looking at your code suggestion above,
    1) (isset($_GET['dwarf']) && !is_numeric($_GET['dwarf'])) &&
    2) && empty($dwarf)
    3) case 'dwarf':
    $select_column_list .= 'e.dwarf';
    4) if (isset($_GET['dwarf']) && zen_not_null($_GET['dwarf'])) {
    $where_str .= " AND e.dwarf = :dwarf";
    $where_str = $db->bindVars($where_str, ':dwarf', $_GET['dwarf'], 'string');
    }

    this doesn't work - and I know the field isn't a string as in number 4.

    When I say it doesn't work - the search page just refreshed itself and never goes to the results page.

    I'm pretty sure I've got the table added correctly to the select statement and even if I didn't, I'm not getting that far!

    What might be wrong?
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

 

 
Page 2 of 6 FirstFirst 1234 ... LastLast

Similar Threads

  1. v139h Custom Advanced Search Fields
    By divinelighting in forum General Questions
    Replies: 0
    Last Post: 27 Jul 2012, 08:22 PM
  2. Modify Advanced Search Fields
    By JimRoster in forum Templates, Stylesheets, Page Layout
    Replies: 11
    Last Post: 9 Oct 2011, 07:41 AM
  3. Modifying the Advanced Search Form Fields?
    By uruharacosplay in forum General Questions
    Replies: 0
    Last Post: 4 Mar 2008, 06:43 PM
  4. Modify Advanced Search Fields
    By icebox500 in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 9 Aug 2007, 10:20 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR