I’m building a blog and I’ve added a simple search plugin.
As for a example I’ve taken a skeleton with search and blog modules.
Let’s assume, that my blog has this URL - /blog
blog.html.twig uses standard URL expressions based on other examples:
{% embed 'partials/base.html.twig' %}
{% set collection = page.collection() %}
{% set base_url = page.url %}
{% if base_url == '/' %}
{% set base_url = '' %}
{% endif %}
{% block content %}
{{ page.content }}
<section class="container-fluid">
<div class="row">
<div class="col-md-8">
{% for child in collection %}
{% include 'partials/blog_item.html.twig' with {'page':child, 'truncate':true} %}
{% endfor %}
</div>
{% include 'partials/blog_sidebar_footer.html.twig' %}
</div>
</section>
{% if config.plugins.pagination.enabled and collection.params.pagination %}
{#% include 'pagination.html.twig' with {'pagination':collection.params.pagination} %#}
{% include 'pagination.html.twig' with {'base_url':page.url, 'pagination':collection.params.pagination} %}
{% endif %}
{% endblock %}
{% endembed %}
blog_sidebar_footer.html.twig is a simple wrapper:
<div class="col-md-4" id="side-bar">
{% include 'partials/sidebar.html.twig' %}
</div>
And sidebar.html.twig:
{% for module in page.collection({'items':{'@taxonomy.category': 'sidebar'},'order': {'by': 'default', 'dir': 'asc'}}) %}
{% if module.template %}
{% if module.header.surround %}
{% include 'sidebar/' ~ module.template ~ '.html.twig' %}
{% endif %}
{% endif %}
{% endfor %}
<div class="sidebar section" id="sidebar">
{% for module in page.collection({'items':{'@taxonomy.category': 'sidebar'},'order': {'by': 'default', 'dir': 'asc'}}) %}
{% if module.template %}
{% if not module.header.surround %}
{% include 'sidebar/' ~ module.template ~ '.html.twig' %}
{% endif %}
{% endif %}
{% endfor %}
{% if config.plugins.simplesearch.enabled %}
<div class="widget HTML">
<h2 class="title">Search</h2>
<div class="widget-content simplesearch">
{% include 'partials/simplesearch_searchbox.html.twig' %}
</div>
</div>
{% endif %}
</div>
So, once I enter some data in search box I get Error 404
The full URL looks like: https://localhost/grav-blog/blog/search/query:test
Exploring examples I assume, that URL should be without /blog/ slug
-> https://localhost/grav-blog/search/query:test
Once I enter URL manually https://localhost/grav-blog/search/
I see Search Results page, but if I add a query
-> array_replace_recursive(): Expected parameter 2 to be an array, string given
What I’m missing? I already tried overwriting all templates with the ones from demo skeletons - but I had no luck…