Skip to content

Commit

Permalink
Add search bar plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Richter committed Oct 16, 2024
1 parent ee65485 commit 73bc0d2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
8 changes: 5 additions & 3 deletions Classes/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ public function __construct(private readonly ElasticSearchServiceInterface $elas



public function indexAction(array $searchParams = []): ResponseInterface
public function indexAction(array $searchParams ): ResponseInterface
{
debug('hier!!');
debug($searchParams);
$language = $this->request->getAttribute('language');
$locale = $language->getLocale();

Expand All @@ -39,16 +41,16 @@ public function indexAction(array $searchParams = []): ResponseInterface

$this->view->assign('totalItems', $elasticResponse['hits']['total']['value']);

$searchParams = $this->request->getQueryParams();
$this->view->assign('searchParams', $searchParams);


$this->view->assign('searchResults', $elasticResponse);
return $this->htmlResponse();
}

public function searchBarAction(): ResponseInterface
public function searchBarAction(array $searchParams = []): ResponseInterface
{
$this->view->assign('searchParams', $searchParams);
return $this->htmlResponse();
}

Expand Down
3 changes: 2 additions & 1 deletion Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ tt_content {
}*/



plugin.tx_lisztcommon_searchbar.view.pluginNamespace = tx_liszt_common_searchlisting
plugin.tx_lisztcommon_searchlisting.view.pluginNamespace = tx_liszt_common_searchlisting
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<f:form name="searchBar" controller="Search" action="index" method="get" extensionName="liszt_common" class="">
<div class="input-group">

<f:form.textfield type="text" name="searchParams[searchText]" value="{searchParams.tx_liszt_common_searchlisting.searchParams.searchText}" class="" aria="{label:'Text input with dropdown button'}" placeholder="" />
<f:form.button class="btn btn-primary" id="button-searchBar">{f:translate(key: 'searchButtonLabel', extensionName: 'liszt_common')}</f:form.button>
<f:form.textfield name="searchParams[searchText]" value="{searchParams.searchText}" class="form-control no-shadow" aria="{label:'Text input with dropdown button'}" placeholder="" />
<f:form.button class="btn btn-outline-dark" id="button-searchBar">{f:translate(key: 'searchButtonLabel', extensionName: 'liszt_common')}</f:form.button>
</div>
</f:form>

Expand Down
1 change: 0 additions & 1 deletion Resources/Private/Templates/Search/Index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ <h4 class="">{key}</h4>

</aside>
<article class="content grid-colspan-lg-2">
<f:render partial="SearchBar" arguments="{_all}" />

<f:for each="{searchResults.hits.hits}" as="hit">
<div class="search-result-item">
Expand Down
8 changes: 4 additions & 4 deletions Resources/Private/Templates/Search/SearchBar.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<f:debug>{_all}</f:debug>
<div class="container-xl">

<f:form name="searchBar" controller="Search" action="index" method="get" extensionName="liszt_common" class="form-inline">
<div class="input-group">
<f:form name="searchBar" controller="Search" action="index" method="get" extensionName="liszt_common" pluginName="SearchListing" class="form-inline" pageUid="18">
<div class="input-group mb-3">

<f:form.textfield name="searchParams[searchText]" value="{searchParams.tx_liszt_common_searchlisting.searchParams.searchText}" class="" aria="{label:'Text input with dropdown button'}" placeholder="" />
<f:form.button class="btn btn-primary" id="button-searchBar">{f:translate(key: 'searchButtonLabel', extensionName: 'liszt_common')}</f:form.button>
<f:form.textfield name="searchParams[searchText]" value="{searchParams.searchText}" class="form-control no-shadow" aria="{label:'Text input with dropdown button'}" placeholder="" />
<f:form.button class="btn btn-outline-dark" id="button-searchBar">{f:translate(key: 'searchButtonLabel', extensionName: 'liszt_common')}</f:form.button>
</div>
</f:form>

Expand Down
5 changes: 1 addition & 4 deletions Resources/Private/Templates/SearchResults.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

<f:section name="Main">

<f:comment>
disable insert searchbar as simple partial because ViewHelper f:form can be used only in extbase context
<f:render partial="SearchBar" arguments="{_all}" />
</f:comment>
<f:cObject typoscriptObjectPath="tt_content.list.20.lisztcommon_searchbar" />

<f:if condition="{f:cObject(typoscriptObjectPath: 'lib.hasContent', data: '{colPos: 0}')}">
<main role="main" id="page-content">
Expand Down

0 comments on commit 73bc0d2

Please sign in to comment.