Forum Discussion

avanvlack's avatar
14 years ago

How to Create an API Question/Search Box

Hello!

 

I am trying to create a search widget for our company homepage that will allow the visitors to our site to ask a question and search the community at the same time. I know this is a REST API call, but I am just wondering if anybody can point me in the right direction. I am sure that somebody else has created a box like this before, and I hoping that somebody can point me to a code example.

 

I have uploaded an image to show the kind of functionality that we were looking for...

 

AskAnswerShare.jpg

 

 

  • xorrkaz's avatar
    xorrkaz
    14 years ago

    This might not be what you're going for, but we did a board-level search component that when executed will take the user to the search interface.  The results are specific to the board from which they searched (plus its TKB).  Here is the code:

     

    <div class="lia-panel lia-panel-standard hp-three-column custom-search-widget">
                    <div class="lia-decoration-border">
                    <div class="lia-decoration-border-top">
                    <div> </div>
             </div>
             <div class="lia-decoration-border-content">
                    <div>
                    <div class="lia-panel-heading-bar-wrapper">
                                    <div class="lia-panel-heading-bar">
                                                    <span class="lia-panel-heading-bar-title">${text.format("custom.search.title")}</span>
                                    </div>
                            </div>
                        <div class="lia-panel-content-wrapper">
                                    <div class="lia-panel-content">
    <form class="lia-form-all-words-input lia-form-type-text lia-form-input-vertical" id="search_monger_form" method="GET" action="/t5/forums/searchpage/tab/message">
      <input type="hidden" id="search_monger_filter" name="filter" value="location" />
      <input type="hidden" id="search_monger_location" name="location" value="Board:${coreNode.id}" />
      <input style="margin: 0px 5px 0px 5px;" type="text" class="lia-form-type-text search-input lia-search-input-message" name="q" id="search_monger_q" value=""><br/>
      <input style="margin: 5px 0px 0px 5px;" type="submit" class="lia-button lia-button-secondary lia-button-searchForm-action" id="search_monger_submit" name="search_submit" value="Search" />
    </form>
                                                                                   </div>
                    </div>
               </div>
                     </div>
             <div class="lia-decoration-border-bottom">
             <div> </div>
             </div>
          </div>
    </div>

     

  • Thank you for your post! This worked perfectly! Much appreciated!!:)

  • Just to clarify... I am not looking for the Ask a Question module that is in studio or a part of the lithium community. I am wondering the best course of action to create a search box for our main website CMS that would post a the form that I create and style to the lithium community and provide the search results that the user provided.

     

    Please Help Point me in the right direction! I must be not using the correct URL in the form post!

     

    If I post to: /t5/community/page.qandaaskexperttaplet.qandaaskexpertform.form.form.form

     

    I get the following error:

    An Unexpected Error has occurred.
    • Sorry, your request failed. A notification has been sent to the development team for investigation.

      Exception ID: 55E52060

      Please click the Back button on your browser.

    • xorrkaz's avatar
      xorrkaz
      Genius

      This might not be what you're going for, but we did a board-level search component that when executed will take the user to the search interface.  The results are specific to the board from which they searched (plus its TKB).  Here is the code:

       

      <div class="lia-panel lia-panel-standard hp-three-column custom-search-widget">
                      <div class="lia-decoration-border">
                      <div class="lia-decoration-border-top">
                      <div> </div>
               </div>
               <div class="lia-decoration-border-content">
                      <div>
                      <div class="lia-panel-heading-bar-wrapper">
                                      <div class="lia-panel-heading-bar">
                                                      <span class="lia-panel-heading-bar-title">${text.format("custom.search.title")}</span>
                                      </div>
                              </div>
                          <div class="lia-panel-content-wrapper">
                                      <div class="lia-panel-content">
      <form class="lia-form-all-words-input lia-form-type-text lia-form-input-vertical" id="search_monger_form" method="GET" action="/t5/forums/searchpage/tab/message">
        <input type="hidden" id="search_monger_filter" name="filter" value="location" />
        <input type="hidden" id="search_monger_location" name="location" value="Board:${coreNode.id}" />
        <input style="margin: 0px 5px 0px 5px;" type="text" class="lia-form-type-text search-input lia-search-input-message" name="q" id="search_monger_q" value=""><br/>
        <input style="margin: 5px 0px 0px 5px;" type="submit" class="lia-button lia-button-secondary lia-button-searchForm-action" id="search_monger_submit" name="search_submit" value="Search" />
      </form>
                                                                                     </div>
                      </div>
                 </div>
                       </div>
               <div class="lia-decoration-border-bottom">
               <div> </div>
               </div>
            </div>
      </div>

       

      • avanvlack's avatar
        avanvlack
        Guide

        Thank you for your post! This worked perfectly! Much appreciated!!:)