1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

New field options not showing in search results

Discussion in 'Templates, HTML, CSS, and Design Help' started by jason1971, May 25, 2015.

  1. jason1971 Customer

    Hi all,
    In phpMyAdmin I have created 2 new fields under class_listings called latedealdes and latedeal
    {$latedealdes} is a general text field and {$latedeal} is a dropdown option field using Y and N as the value (as shown below).
    latedeal enum('Y', 'N') utf8_general_ci Yes NULL
    I then went on and added the 2 fields in public_html/administration/listings.php and public_html/includes/classes/kernel/listings.php (by copying the same code used for {$description} in all the same places in both Listings.php). Both fields show up as they should on the admin side and on the frontend side.

    **THE ISSUE**
    My issue is with the dropdown field and the search results.
    I have setup a custom search form on home.tpl and added the dropdown like this.
    <label for="latedeal" >Late deal to offer</label> <select name="latedeal">
    <option value="N"{if $latedeal == "N"} SELECTED{/if}>No</option>
    <option value="Y"{if $latedeal == "Y"} SELECTED{/if}>Yes</option>
    </select>

    The search is not searching and acting on the dropdown options, I have used the debug and it is showing up correctly under {$results} latedeal => "Y"


    I am assuming I would have to add some sort of database query to pull the values ??

    The reason for not using the built in extra fields is because I want to show only those 2 fields in a separate highlighted part on usermodifylisting.tpl (which I have done with no probs).

    Sorry able the rambling on and I hope it makes some sense to you.
    Thanks a million for any help this has been driving me mad trying to work out over the weekend.

    Jason.
  2. Mike-N-Tosh Owner

    They are not going to show up in a search as extra fields are not stored in the listings table when created properly in the administration section. They are stored in 3 completely separate tables. One for the extra fields themselves. One in a join table to associate them with whatever category(ies) that they are associated with and one for the actual values as filled in when the listing is created.

    So when a search is done, it searches the listings table for matches (e.g. title, description, etc.) and then the field values table. As your custom fields aren't in the fields values table, they're not going to be found.

    If it were me, I would create the fields within the admin as you normally would. Set them NOT to show, searchable and then use the smarty plugin, "function.get_extra_field.php" in the template files that you want to show them in.
  3. jason1971 Customer

    Hi Mike,

    Thanks for the reply.

    Would there be any way of somehow adding the latedeal as one of the search parameters ????, as I also wish to use the field in other areas of my website on both backend and frontend which I know the extra_fields would not be suitable.


    Cheers Jason
  4. Mike-N-Tosh Owner

    Search with the extra fields is the most complex code of the entire classifieds script. Of course what you're suggesting is possible, however it is extremely complex to implement. I never suggest modifying the core ".php" files to begin with for several reasons, mainly the complexity it adds to be able to upgrade the site when a newer version comes out.

    The two best ways to handle what you've described are what I've already suggested, creating the extra fields the way you normally do in the administration and use the plugin to display them wherever you want them. I honestly can't think of any circumstance where this wouldn't work except one, where you're wanting to find all listings with a latedeal. which leads me to other way...

    The other way would be to develop an actual module for it. The built in search already includes several module hooks.
  5. jason1971 Customer

    Hi Mike,

    Thanks for your reply, just typical that the one part I need altering ends up being the most complex :mad: ohh well.

    I am certainly not asking you to create a mod for me, but if you could offer some pointers I think I would not mind having a go at creating one :eek: as I feel more and more comfortable getting to know the script (well so far so good).

    Cheers
    Jason
  6. Mike-N-Tosh Owner

    Documentation for writing modules for 68 Classifieds can be found in the online documentation here:
    http://www.68classifieds.com/documentation/development/start

    Look for module hooks in the php code for any of the routines where the functionality that you are creating involves. As an example, step3 of the checkout ("details") involves the usercheckout.php which also calls step3.php and step3 also calls Core and Listings.

    Whenever you see something similar to:
    PHP:
    $variable $Libraryname->functionName($param1$param2);
    $Libraryname will be the name of the class file (minus the .php) being called
    After the "->" is the name of the function in that class file being called [ e.g. function functionName($param1, $param2, ...) ]
    Look for any module hook within that function that may be available to you. A modulehook in a php file will look like this:
    PHP:
    $modules->call_hook('listing_modify'$id);
    Also bear in mind that template files will sometimes have module hooks too, like in the header of the layout.tpl:
    Code:
    {modulehook function="tpl_layout_head" options=""}
    Those use the smarty plugin "function.modulehook.php", this means that you can also put a modulehook in any template wherever you want one using the same syntax.
    Code:
    {modulehook function="tpl_my_modulehook" options=""}
    Best of luck.
  7. jason1971 Customer

    Thanks Mike for the info, will have a go and see how I get on.

Share This Page