Follow the tutorial about filter and sorting and reading the devdocs.
My questions:
When loading the page for the first time...
1.In the tutorial, at starting point showing all the post-results, but is there a way, see results ONLY when typing a searchterm in the input field?
- is it also possible when there is no searchterm in the input-field, show a text (example: welcome to my site) otherwise, show the results? Maybe with the if...else... structure?
Can someone advice me with this?
What i will try to make is a simple searchform like on the https://automad.org/ website => only show results when typing a searchterm.
My code below shows all results, but i want only show results when typing a searchterm 😖
Thats my code so far:
<form action="" method="get" class="searchform">
<input type="text" class="form-control" placeholder="Search..." value="@{ ?search }" name="search">
<span><a href="#">Search</a></span>
</form>
<@ newPagelist { type: 'children' , context: '/provincies' , search: @{ ?search }, filter: false } @>
<p>counter: @{ :pagelistDisplayCount }</p>
<@ if @{ :pagelistDisplayCount } < 1 @>
<p>Nothing found!</p>
<@ else @>
<@ foreach in pagelist @>
<p><a href="@{ url }">@{ title }</a></p>
<@ end @>
<@ end @>