Download the PHP package imarc/craft-googlecustomsearch without Composer
On this page you can find all versions of the php package imarc/craft-googlecustomsearch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download imarc/craft-googlecustomsearch
More information about imarc/craft-googlecustomsearch
Files in imarc/craft-googlecustomsearch
Package craft-googlecustomsearch
Short Description A Craft plugin for integrating with Google's Custom Search (and Google's Site Search.)
License Apache-2.0
Informations about the package craft-googlecustomsearch
Google Custom Search plugin for Craft CMS 3.x
A Craft CMS plugin that incorporates a Google Custom Search into your website.
Google offers free and paid tiers for accessing their search results.
If you are looking for the Craft 2 version of this plugin, see the craft2
branch.
Requirements
This plugin requires Craft CMS 3.0.0 or later.
Installation
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require imarc/craft-googlecustomsearch
- In the Control Panel, go to Settings → Plugins and click the “Install” button for googlecustomsearch.
Configuring
You will need a Search Engine ID and API Key from Google.
Search Engine ID - On the Custom Search Engine Control Panel, create a new search engine for the site you would like to integrate. Once created, you can retrieve your Search Engine ID from the Setup tab.
API Key - If you're using the free tier, visit the Google Developers Console and create a project for your search engine. Within your project, you’ll need to enable the Custom Search API from the APIs tab. Finally, on the Credentials tab, you will need to create a Public API access key by selecting the Create new Key option and choosing Server key. The API Key will now be available. If you're using a paid tier, you can find your API key in the Control Panel in the Business > XML & JSON tab.
The credentials can either be added from Craft's plugin settings or within config/googlecustomsearch.php
.
Usage
In your twig template, retrieve search results from Google by passing it your search query, which you can then iterate over to display:
Here is a complete example with pagination:
Credits
Brought to you by Imarc