Support Forums

Preselected Category for Search

This is a discussion on Preselected Category for Search within the Modules / Plugins / Modifications forums, part of the Developer Forums category; It seems to be a common change to want a category to be pre-selected when visiting the search form. This ...


Go Back   68 Classifieds Forums > Developer Forums > Modules / Plugins / Modifications

Reply
 
Thread Tools Display Modes
Old 09-19-2008, 12:15 PM   #1
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,497
Rep Power: 132
Eric Barnes is just really nice Eric Barnes is just really nice
Default Preselected Category for Search

It seems to be a common change to want a category to be pre-selected when visiting the search form. This modification will allow that.

V4.0.x

#1. Open search.tpl and find the closing </form> tag.

#2. Just below it add:
Code:
{literal}
<script type="text/javascript">
    selectedCat(1); //where 1 is the category pre selected.
    function selectedCat(type){
        document.getElementById('ajxresponse').innerHTML = '';
        var QSTRING = type;
        cp.call('{/literal}{$smarty.const.URL}{literal}/ajax.php', 'ajax_extra_search_fields', response, QSTRING);
        return false;
    }
</script>
{/literal}
Please keep in mind you can only have one preselected and in this example the category had an id of 1.

V4.1.x Beta
#1. Open search.tpl and find the following code:
Code:
$(document).ready(function() {
#2. Just below it add:
Code:
selectedCat(1); //where 1 is the category pre selected.
    function selectedCat(type){
        $("#response").show()
        $.ajax({
            url: 'ajax.php',
            data: 'action=extra_listing_fields&do=search§ion=' + type,
            type: 'post',
            success: function (msg) {
                $("#response").html(msg);
            }
        });
    }
Please keep in mind you can only have one preselected and in this example the category had an id of 1.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules

Last edited by Eric Barnes; 12-23-2008 at 12:49 PM.
Eric Barnes is offline   Reply With Quote
Old 11-15-2008, 09:54 PM   #2
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 2,993
Rep Power: 73
seymourjames is a jewel in the rough
Default

That is a nice mod and useful. Is there a way to get the same action if the same extrafields apply to all categories. In other words, the extrafields drop down automatically by default?

At present, if the mod is applied to the search form, the select all comes up by default (regardless of the cat id put in) and the extrafields drop down (the right action for my need), if you then do a search on a specific category it is fine also but then if you go back and 'select all' without refreshing the page, the extrafields in the search form disappear. Logic which is something like if select all then drop the extrafields.
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68 Classifieds Version 5 Themes and Version 4 Templates
seymourjames is offline   Reply With Quote
Old 12-23-2008, 09:35 AM   #3
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 77
Rep Power: 10
DGiscombe is on a distinguished road
Default

Hi Eric,

Is there a different code to use for v4.1.0 Beta 5 which has the same outcome.

Reason why I would like this is because the searchable date field only works on this version and that is the one I'd like to target for the search without having to select a category first.

This question is open to anyone of course.
DGiscombe is offline   Reply With Quote
Old 12-23-2008, 12:05 PM   #4
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,497
Rep Power: 132
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Yes it would be different code. I will have to do some testing on it before I can post the change.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 12-23-2008, 12:15 PM   #5
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 77
Rep Power: 10
DGiscombe is on a distinguished road
Default

Excellent.

Thanks Eric, got something to tell my client now
DGiscombe is offline   Reply With Quote
Old 12-23-2008, 12:49 PM   #6
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,497
Rep Power: 132
Eric Barnes is just really nice Eric Barnes is just really nice
Default

I just edited the first post in this topic with instructions for v4.1 beta.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 12-23-2008, 01:14 PM   #7
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 77
Rep Power: 10
DGiscombe is on a distinguished road
Default

Genius!

I've now stripped out the option box all together so that it only shows "starts from" and the search button. If I get the calendar to stay there instead of popping up, that can be my 'bare bones' event calendar.

Thank you very much Eric.
DGiscombe is offline   Reply With Quote
Old 01-15-2009, 10:17 PM   #8
Customer
 
Join Date: Jan 2009
Posts: 27
Rep Power: 9
naidu01 is on a distinguished road
Default Can this be modified to autoselect category

Hello Eric,
I added this code to a search box that I added to the left menu. Can this script be modified to auto-select the category/subcategory that the user has clicked into?
naidu01 is offline   Reply With Quote
Old 12-27-2009, 08:29 PM   #9
Junior Member
 
Join Date: Dec 2009
Posts: 4
Rep Power: 0
Bone is on a distinguished road
Default Preselected category produces error

Quote:
Originally Posted by Eric Barnes
It seems to be a common change to want a category to be pre-selected when visiting the search form. This modification will allow that.

V4.0.x

#1. Open search.tpl and find the closing </form> tag.

#2. Just below it add:
Code:
{literal}
<script type="text/javascript">
    selectedCat(1); //where 1 is the category pre selected.
    function selectedCat(type){
        document.getElementById('ajxresponse').innerHTML = '';
        var QSTRING = type;
        cp.call('{/literal}{$smarty.const.URL}{literal}/ajax.php', 'ajax_extra_search_fields', response, QSTRING);
        return false;
    }
</script>
{/literal}
Please keep in mind you can only have one preselected and in this example the category had an id of 1.

V4.1.x Beta
#1. Open search.tpl and find the following code:
Code:
$(document).ready(function() {
#2. Just below it add:
Code:
selectedCat(1); //where 1 is the category pre selected.
    function selectedCat(type){
        $("#response").show()
        $.ajax({
            url: 'ajax.php',
            data: 'action=extra_listing_fields&do=search§ion=' + type,
            type: 'post',
            success: function (msg) {
                $("#response").html(msg);
            }
        });
    }
Please keep in mind you can only have one preselected and in this example the category had an id of 1.
I made the modification to the search.tpl from templatecodes 3 column template system and it loaded the page with errors.
The when a category is selected from category dropdown, none of the category specific extra fields show.
Is this code / modification valid for 4.1.6 Developer editions using templatecodes template?
__________________
Developer 4.1.6 - Evo 3 col Template
Bone is offline   Reply With Quote
Old 12-27-2009, 08:51 PM   #10
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 2,993
Rep Power: 73
seymourjames is a jewel in the rough
Default

I see no reason why it should not work if indeed it does work for 4.1.6. Try it on the default template (search.tpl) and see if it works. The only difference in the search.tpl file supplied by templatecodes is the styling of it. No structural change has been made.

If it does not work on the default template it is then a case of it does not work or you have not implemented the modification correctly. Let us know.
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68 Classifieds Version 5 Themes and Version 4 Templates
seymourjames is offline   Reply With Quote
Reply

Tags
category , search

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Modification: RSS Feeds by Category (or anything else) jonahcoyote Modules / Plugins / Modifications 20 06-19-2009 01:16 PM
Display all ads and their category hel68c Modules / Plugins / Modifications 5 08-21-2008 05:36 PM
Mass Move listings of a category to another category Success Technical Support 3 04-10-2008 11:01 AM


All times are GMT -4. The time now is 10:38 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0