Forum Discussion

FranzG's avatar
FranzG
Genius
11 years ago

List of available parameters for common.widget.search-form component?

Hi,

 

Anybody know if there is documentation or a list of the parameters available for passing to the default common.widget.search-form component?

 

I was only able to locate these:

hideGranularity
showAdvancedSearchLink
searchType

My goal is to limit the scope of the standard search component to a specific category or coreNode. I've added the common.widget.search-form to custom pages and don't want those searches to happen at the community level. Fingers crossed that there is some parameter to specify the highest node the search should check. I'm hoping I don't have to manually pull in and format the search results using the REST search APIs.

 

I saw a post about the "searchType" parameter but it doesn't appear to have many possible values: https://community.lithium.com/t5/Support-board/Standard-components-parameters/m-p/97136/highlight/true#M4768

I'm trying to customize the search to only show results for a specific blog.

 

Thanks!

  • Hi,

     

    the standard search widget usually searches results based on the node it's being rendered in. So - if it's rendered on the community page, it will search at community level. If it's rendered on a category page , it will search within that category and on a blog page within that blog etc ...

     

    One configuration element that can be used is 

     

    defaultToCommunity=true

    To default the search on all the community. I don't think at the moment there is configuration available to force a search within a particular board - this would have to be a customization possibly. For example, look at the URL parameters available in the search result page http://community.lithium.com/t5/forums/searchpage/tab/message?location=board%3Alithiumblog&q=search&search_type=thread&filter=labels%2Clocation (this is a search for a term on the Lithium's views blog) - you may be able to construct a widget based on that.

     

    Alternatively - you can get in touch with Lithium Professional Services to help you in scoping and delivering this.

     

    Thanks,

  • if anyone comes looking, you can override common.widget.search-form@override and add this JavaScript. This will scope it to the particular forum.

    <@liaAddScript>
    ;(function($){
    
      var nodeType = "${coreNode.nodeType}";
    
      if (nodeType === "board") {
       var boardId = "${coreNode.id}";
    
       var inputFormFilter = '<input name="filter" value="location" type="hidden">';
       var inputFormLocation = '<input name="location" value="board:' + boardId + '" type="hidden">';
       $('form[action*="searchform.form.form"]').append(inputFormFilter).append(inputFormLocation);
      }
    
    })(LITHIUM.jQuery)
    </@liaAddScript>
    
    <@delegate />

     

    • robertcavanna's avatar
      robertcavanna
      Mentor

      gstelang wrote:

      if anyone comes looking, you can override common.widget.search-form@override and add this JavaScript. This will scope it to the particular forum.

      <@liaAddScript>
      ;(function($){
      
        var nodeType = "${coreNode.nodeType}";
      
        if (nodeType === "board") {
         var boardId = "${coreNode.id}";
      
         var inputFormFilter = '<input name="filter" value="location" type="hidden">';
         var inputFormLocation = '<input name="location" value="board:' + boardId + '" type="hidden">';
         $('form[action*="searchform.form.form"]').append(inputFormFilter).append(inputFormLocation);
        }
      
      })(LITHIUM.jQuery)
      </@liaAddScript>
      
      <@delegate />

       


      gstelang where would this type of script go? In a custom component, or just anywhere on the page where you want to override the context of the search component or elsewhere?

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)

    Hi,

     

    the standard search widget usually searches results based on the node it's being rendered in. So - if it's rendered on the community page, it will search at community level. If it's rendered on a category page , it will search within that category and on a blog page within that blog etc ...

     

    One configuration element that can be used is 

     

    defaultToCommunity=true

    To default the search on all the community. I don't think at the moment there is configuration available to force a search within a particular board - this would have to be a customization possibly. For example, look at the URL parameters available in the search result page http://community.lithium.com/t5/forums/searchpage/tab/message?location=board%3Alithiumblog&q=search&search_type=thread&filter=labels%2Clocation (this is a search for a term on the Lithium's views blog) - you may be able to construct a widget based on that.

     

    Alternatively - you can get in touch with Lithium Professional Services to help you in scoping and delivering this.

     

    Thanks,

    • FranzG's avatar
      FranzG
      Genius

      Oh well, I figured it might have to be a custom solution.  Was hoping there might be a list of parameters some where.

       

      Thanks PaoloT!

      • SuzieH's avatar
        SuzieH
        Khoros Alumni (Retired)

        Here is documentation from the Studio hovercard component help for Search Form. 

         

        The parameters you can use differ depending on whether you are using Search v1 or v2. 

         

        Search V 1.0 settings are configured in Community Admin > System > Search> Search 1.0. Be sure that Search 2.0 is disabled in the Search 2.0 tab, if visible.

         

        In the XML tab you can configure the component to hide the drop down list that enables uses to choose the scope of their search, to use a slim or wide display model, and to default the scoping options to a Community-level scope.

         

        Search V1 supports the parameters: hideGranularity, and defaultToCommunity.

        Search V2 supports the parameters: mode, hideGranularity, defaultToCommunity

         

        To hide the drop down list to scope the search add: hideGranularity="true"

        To default the scope of the search to be community-wide add: defaultToCommunity="true"

        To change the component width, add: mode="slim" or mode="wide"

        We have documented available XML parameters for the components that use them in the Where Do I Configure This section of the Studio inline help. Here's an example: