68 Classifieds Forums

Preselected Category for Search

This is a discussion on Preselected Category for Search within the v4 Modules / Modifications forums, part of the Help & Support 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 > Help & Support > v4 Modules / Modifications

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 09-19-2008, 12:15 PM
Eric Barnes's Avatar
68 Classifieds Staff
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,307
Rep Power: 99
Eric Barnes is a jewel in the rough
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&section=' + 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
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | Twitter

Last edited by Eric Barnes; 12-23-2008 at 12:49 PM.
Reply With Quote
  #2  
Old 11-15-2008, 09:54 PM
Moderator
 
Join Date: Mar 2008
Posts: 553
Rep Power: 16
seymourjames has a spectacular aura about
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.
__________________
Version 4.09
TemplatesCodes.com For 68C
Reply With Quote
  #3  
Old 12-23-2008, 09:35 AM
Member
 
Join Date: Nov 2008
Posts: 33
Rep Power: 1
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.
Reply With Quote
  #4  
Old 12-23-2008, 12:05 PM
Eric Barnes's Avatar
68 Classifieds Staff
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,307
Rep Power: 99
Eric Barnes is a jewel in the rough
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
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | Twitter
Reply With Quote
  #5  
Old 12-23-2008, 12:15 PM
Member
 
Join Date: Nov 2008
Posts: 33
Rep Power: 1
DGiscombe is on a distinguished road
Default

Excellent.

Thanks Eric, got something to tell my client now
Reply With Quote
  #6  
Old 12-23-2008, 12:49 PM
Eric Barnes's Avatar
68 Classifieds Staff
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,307
Rep Power: 99
Eric Barnes is a jewel in the rough
Default

I just edited the first post in this topic with instructions for v4.1 beta.
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | Twitter
Reply With Quote
  #7  
Old 12-23-2008, 01:14 PM
Member
 
Join Date: Nov 2008
Posts: 33
Rep Power: 1
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.
Reply With Quote
Reply

Bookmarks

Tags
category, search

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Display all ads and their category hel68c v4 Modules / Modifications 5 08-21-2008 05:36 PM
Modification: RSS Feeds by Category (or anything else) jonahcoyote v4 Modules / Modifications 3 07-01-2008 12:37 PM
Mass Move listings of a category to another category Success v4 Questions & Support 3 04-10-2008 11:01 AM
Hide a category on public pages? HotAir v3.1 Questions & Support 6 12-05-2007 11:17 AM
Branding each Category BABBSELA v3.1 Modules & Modifications 0 02-10-2007 02:17 PM


All times are GMT -4. The time now is 04:42 PM.


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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22