But that option has ads and I want a clean version. The issue is that google is shutting down their paid version of custom search - https://cse.google.com/cse/
Swiftype Site Search is a good alternative to Google Custom Search. It's easy to set up and comes with a dashboard where you can customize your search experience and view analytics. A few cool features:
- custom result ranking
- faceted search
- autocomplete dropdown
Swiftype's API is extensively documented and you can customize the search UI to match your templates. You can index any amount of content with Swiftype and new content is indexed automatically.
Hi, try using the Google's Site Search (which is actually their paid service for site search tools). https://cse.google.com/compare. Also, I could not find any information about Google shutting down their paid search service for websites.
That module was actually written by @stefen who is a regular on these boards. Maybe he could chime in with some modification help.
I actually just created a custom search for a resource page that checked the searched term against all of the blogs components (title, content, image, custom module content) and returned any matches on the listing page. This would work for a site wide search except that I cannot seam to find a token that contains the published pages.
and a custom for contents loop if a query is present in the url:
{% if query is defined %}
{% for content in contents %}
{% set title = content.widgets.resource_title.body.value|lower %}
{% set type = content.widgets.resource_content_type.body.value|lower %}
{% set summary = content.widgets.resource_content_type.body.value|lower %}
{% set topic = in content.topic_list|map('name')|lower %}
{%if query in title or query in type or query in summary or query in topic %}
<div class="resource_item {{ content.widgets.resource_content_type.body.value|lower }}">
<a class="resource_featured_image" href="{{ content.widgets.resource_link.body.value }}" style="background: url({{ content.widgets.resource_image.body.src }});"></a>
<h2><a href="{{ content.widgets.resource_link.body.value }}">{{ content.widgets.resource_title.body.value }}</a></h2>
<div class="sum_wrap">
{{ content.widgets.resource_summary.body.value }}
</div>
<a class="resource_read_more" href="{{ content.widgets.resource_link.body.value }}">{{ content.widgets.resource_button_text.body.value }}</a>
</div>
{% endif %}
{% endfor %}
{% endif %}
This was based off of a request to have the clients resource page searchable like Hubspots search page. It works pretty much the same.
This would work in your case to only you would need to redirect to a different page with the query and use an array like contents that gives you access to all of the pages on your site. I can't seam to find anything that allows this. without having access to all of the pages and their content to loop through this won't work.
{% for content in contents %} {% set title = content.widgets.resource_title.body.value|lower %} {% set type = content.widgets.resource_content_type.body.value|lower %} {% set summary = content.widgets.resource_content_type.body.value|lower %} {% set topic = in content.topic_list|map('name')|lower %} {%if query in title or query in type or query in summary or query in topic %} <div class="resource_item {{ content.widgets.resource_content_type.body.value|lower }}"> <a class="resource_featured_image" href="{{ content.widgets.resource_link.body.value }}" style="background: url({{ content.widgets.resource_image.body.src }});"></a> <h2><a href="{{ content.widgets.resource_link.body.value }}">{{ content.widgets.resource_title.body.value }}</a></h2> <div class="sum_wrap"> {{ content.widgets.resource_summary.body.value }} </div> <a class="resource_read_more" href="{{ content.widgets.resource_link.body.value }}">{{ content.widgets.resource_button_text.body.value }}</a> </div> {% endif %} {% endfor %} {% endif %}
{% set title = content.widgets.resource_title.body.value|lower %} {% set type = content.widgets.resource_content_type.body.value|lower %} {% set summary = content.widgets.resource_content_type.body.value|lower %} {% set topic = in content.topic_list|map('name')|lower %}
{%if query in title or query in type or query in summary or query in topic %}
I placed the query variable and the search bar w/ javascript in a custom HubL module outside of the listing and post template code, in the main template. This is because they share a search bar so I needed it for both instead of one or the other.
It doesn't matter where you place your query variable as long as you have it above the code that references it.
You are correct about the code that you placed in your listing template.
I've been trying to implement this into a blog search for the past few days and have been having a hard time. I can successfully search through titles and content, but topics are still evading me.
I would imagine that the "is string_containing" part is the issue. I might be wrong but I am pretty sure that the topics are delivered as a dict containing the slug and the topic name. I haven't had this issue before. I wrote a blog post about this method: http://www.khaoticdigital.com/blog/simple-hubspot-blog-search-function
% if query in title or query in post or query in topics %}
hasn't let me down yet, though I can't honestly say I remember whether or not I actually tested topics. I am pretty sure I did. The same search is implemented on my blog there.