Commit df2160c0 authored by Andreas Fernandez's avatar Andreas Fernandez Committed by Markus Klein
Browse files

[BUGFIX] Only show search on non-empty pages

If a page has neither content nor subpages, do not show the search button
in the backend.

Resolves: #72027
Releases: master
Change-Id: Iff2657a203f25123c288ea48e6fc553483bdd254
Reviewed-on: https://review.typo3.org/45090


Reviewed-by: default avatarMichael Oehlhof <typo3@oehlhof.de>
Tested-by: default avatarMichael Oehlhof <typo3@oehlhof.de>
Reviewed-by: default avatarDaniel Goerz <ervaude@gmail.com>
Tested-by: default avatarDaniel Goerz <ervaude@gmail.com>
Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
parent f0f1d0b8
......@@ -997,7 +997,7 @@ class PageLayoutController
$content .= $output;
}
// Making search form:
if (!$this->modTSconfig['properties']['disableSearchBox'] && !empty($tableOutput)) {
if (!$this->modTSconfig['properties']['disableSearchBox'] && ($dbList->counter > 0 || $this->currentPageHasSubPages())) {
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox');
$toggleSearchFormButton = $this->buttonBar->makeLinkButton()
->setClasses('t3js-toggle-search-toolbox')
......@@ -1529,4 +1529,23 @@ class PageLayoutController
$this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($languageMenu);
}
}
/**
* Checks whether the current page has sub pages
*
* @return bool
*/
protected function currentPageHasSubPages()
{
$count = $this->getDatabaseConnection()->exec_SELECTcountRows(
'uid',
'pages',
'pid = ' . (int)$this->id
. BackendUtility::deleteClause('pages')
. BackendUtility::versioningPlaceholderClause('pages')
. BackendUtility::getWorkspaceWhereClause('pages')
);
return $count > 0;
}
}
......@@ -563,14 +563,16 @@ class RecordList extends AbstractModule
if (!$this->modTSconfig['properties']['disableSearchBox'] && ($dblist->HTMLcode || !empty($dblist->searchString))) {
$this->content = $dblist->getSearchBox();
$this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox');
$searchButton = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->makeLinkButton();
$searchButton
->setHref('#')
->setClasses('t3js-toggle-search-toolbox')
->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchIcon'))
->setIcon($this->iconFactory->getIcon('actions-search', Icon::SIZE_SMALL));
$this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->addButton($searchButton,
ButtonBar::BUTTON_POSITION_LEFT, 90);
}
$searchButton = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->makeLinkButton();
$searchButton
->setHref('#')
->setClasses('t3js-toggle-search-toolbox')
->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchIcon'))
->setIcon($this->iconFactory->getIcon('actions-search', Icon::SIZE_SMALL));
$this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->addButton($searchButton, ButtonBar::BUTTON_POSITION_LEFT, 90);
if ($this->pageinfo) {
$this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment