XenForo Tutorials

Add Google Custom Search form to your Advance Search

Submitted by Yondu, , Thread ID: 197750

12-02-2021, 08:59 PM
#1
This will add a Google custom search form to your xenForo Advanced Search and will do a Google search of your site/s.

You will of course first need to sign up and have registered your site/s with Google CSE

Once you have configured that you will be able to get the code you can add to the form

1. At the end of the template search_form add the following. Text in capitals is to be replaced.

Code:
<xf:comment>Google Custom Serach Form starts here</xf:comment>
        <div class="block-container">
            <div class="block-body block-row">
                <h1 class="p-title-value">TITLE E.G. GOOGLE CUSTOM SEARCH</h1>
                <span class="ADD CSS CLASS FOR YOUR TEXT (OPTIONAL)">ADD YOUR  TEXT HERE (OPTIONAL)</span>
        
ADD THE GOOGLE SCRIPT HERE
        
                <div>
                    <gcse:searchresults>
                    </gcse:searchresults>
                </div>
            </div>
        </div>

Note that this includes the code for the search results, so you only need the first first stage when you click the Google CSE Get Code button (it's bit confusing)

Tip: Change the phrase advanced_search to add a description to that button
[Image: wsUuw16j6oyxLLRnnK.gif]

Users browsing this thread: 1 Guest(s)