Forum Discussion

qinglau's avatar
qinglau
Mentor
12 years ago

Custom drop down section in common.widget.search-form

Hi All, 

 

I build a simple custom component at my end. The custom component contains the "standard common.widget.search-form".  I would like to hide two options in the default drop down menu. (please see the attachment). 

 

I have a solution in my mind is to add javascript in the page hint box part. 

 

//Find the option to hiden
jQuery('#searchGranularity').find([value="tkb|tkb"]').remove

 

I do not think this is the best solution. If i want to overrwirte the componment , how i can do that? or even there is a setting to turn it off. 

 

Thank you 

 

Cheers,
Qing 


18-9-2013 10-00-34.png

5 Replies

  • AdamA's avatar
    AdamA
    Khoros Oracle
    12 years ago

    Hello,

     

    There is a (undocumented?) parameter of the common.widget.search-form that you can use to hide the search drop down. The parameter is hideGranularity which you can set to true. Here is an example:

     

    <@component id="common.widget.search-form" hideGranularity="true" />
  • qingliu's avatar
    qingliu
    Contributor
    12 years ago
    Thanks Adam, it works. However, do you know whether it is possible to hide only the selected drop down menu? like i have 4 options, board, community, category, TKB and users. I would like to hide the TKB selection option.

    Do u think it is a way to do that without using javascript to find element and hide?

    Cheers,
    Qing
  • AdamA's avatar
    AdamA
    Khoros Oracle
    12 years ago
    Qing,

    Sorry, I missed your initial question. There is currently not a config/setting/parameter that will allow you to just hide the TKB select option item, aside from disabling the TKB feature. Currently I think JavaScript is your only option.

  • qinglau's avatar
    qinglau
    Mentor
    12 years ago

    Hi Adam,

     

    Here is my solution , i build a custom componment and nested the common search form widget in here and use JavaScript to select first option in the drop down menu, the CSS is applied to hide drop down menu.

     

    <div id="kpn_main_search">
    
    <div id="kpn_main_search_title"><span>Een vraag stellen</span></div>
    <a class="lia-search-page-link" href="/t5/forums/searchpage/tab/message">${text.format("custom.page.search.advancedsearchlink")}</a>
    <@component id="common.widget.search-form" />
    </div>
    
    <!--Search script-->
    <@liaAddScript>
    $( document ).ready(function() {
             var search = $('#searchGranularity option:first').val($("#target option:first").val());
    });
    </@liaAddScript>

     

     

    i have another question, is there a way to force the search type, for instance, i want to the common widget search form only searches the Forum not blog.  Is it possible?

     

    Thank you

    common.widget.search-form