Problem with Display extra field in Search

Discussion in 'Technical Support' started by jw4, Feb 20, 2011.

Thread Status:
Not open for further replies.
  1. jw4 New Member

    Version 4.1.10 developer
    Default Template

    I have an extra field (Your School) which is set for display and search for all categories.

    In Search, default displayed is 'Search All' - when this is used/reselected, the extra field is not displayed. If a category is selected, then the extra field is shown.

    I want the extra field to always be shown. I have looked at search.tpl and ajax.php but I don't know what exactly to change.

    Can anyone help?

    Attached screenshots for Search All (no extra field) and category Clothes (extra field displayed)

    Many thanks
    Jane

    Attached Files:

  2. John Snyder Staff

    Provided you are only loading a single field for all categories, you can edit the javascript to prevent updating based on the change of the category. Something like this:

    Replace this section of search.tpl with either of the two below:

    Code:
    $("#type").change(function()
    {
        $("#response").show();
        $("#optResponse").hide();
        //alert($('#type option:selected').val());
        $.ajax({
            url: 'ajax.php',
            data: 'action=extra_listing_fields&do=search§ion=' + $('#type option:selected').val(),
            type: 'post',
            success: function (msg) {
                $("#response").html(msg);
            }
        });
    });
    
    Code:
    var type = 1; //this must be a universal extra field that never changes
     $.ajax({
            url: 'ajax.php',
            data: 'action=extra_listing_fields&do=search§ion=' + type,
            type: 'post',
            success: function (msg) {
                $("#response").html(msg);
            }
     });
    
    Or you can resubmit every time the category is changed, the field if global will be reloaded along with any others:

    Code:
    var default_type = 1; // will default to this categories extra fields
    $("#type").bind('change', function() {
        $("#response").show();
        $("#optResponse").hide();
        type = $('#type option:selected').val(); 
        if (type == '') { //every time select all is chosen it will return to the default category fields
            type = default_type;
        }
        $.ajax({
            url: 'ajax.php',
            data: 'action=extra_listing_fields&do=search§ion=' + type,
            type: 'post',
            success: function (msg) {
                $("#response").html(msg);
            }
        });
    });
    $("#type").trigger('change');
    
  3. jw4 New Member

    Hi John

    Problem solved with your code.

    Many, many thanks
    Jane
Thread Status:
Not open for further replies.

Share This Page