Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include global search output in initialData #2

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .build/phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer">
<config name="installed_paths" value="../../slevomat/coding-standard"/>
<config name="installed_paths" value="../../slevomat/coding-standard" />
<rule ref="Generic.Arrays.DisallowLongArraySyntax">
<type>error</type>
</rule>
Expand Down
13 changes: 10 additions & 3 deletions Classes/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use FriendsOfTYPO3\Headless\Utility\FileUtility;
use Psr\Http\Message\ResponseInterface;
use Remind\Headless\Service\JsonService;
use Remind\Headless\Utility\ConfigUtility;
use Remind\HeadlessSolr\Event\ModifySearchDocumentEvent;
use TYPO3\CMS\Extbase\Service\ImageService;

Expand Down Expand Up @@ -42,9 +43,15 @@ public function formAction(): ResponseInterface
{
parent::formAction();

$config = Util::getSolrConfiguration();
$targetPageUid = $config->getSearchTargetPage();
$getParameter = $config->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.getParameter', 'q');
$pageConfig = ConfigUtility::getConfig();

$solrConfig = Util::getSolrConfiguration();

$targetPageUid = isset($this->settings['global'])
? ((int) ($pageConfig['solr']['searchPage'] ?? 0))
: $solrConfig->getSearchTargetPage();

$getParameter = $solrConfig->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.getParameter', 'q');

$arguments = $this->request->getArguments();

Expand Down
22 changes: 22 additions & 0 deletions Configuration/FlexForms/Config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<T3DataStructure>
<sheets>
<solr>
<ROOT>
<sheetTitle>LLL:EXT:rmnd_headless_solr/Resources/Private/Language/locallang.xlf:flexform.config.sheet_title</sheetTitle>
<type>array</type>
<el>
<solr.searchPage>
<label>LLL:EXT:rmnd_headless_solr/Resources/Private/Language/locallang.xlf:flexform.config.search_page</label>
<config>
<type>group</type>
<allowed>pages</allowed>
<maxitems>1</maxitems>
<size>1</size>
</config>
</solr.searchPage>
</el>
</ROOT>
</solr>
</sheets>
</T3DataStructure>
12 changes: 9 additions & 3 deletions Configuration/TCA/Overrides/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

defined('TYPO3') || die;

use Remind\Headless\Utility\ConfigUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

ExtensionManagementUtility::addTCAcolumns(
Expand All @@ -15,10 +16,13 @@
'maxitems' => 1,
],
],
]
]
);

// Replace no_search and no_search_sub_entries fields with empty palette to remove, they will be added to a new palette below
/**
* Replace no_search and no_search_sub_entries fields with empty palette to remove,
* they will be added to a new palette below
*/
foreach (['no_search', 'no_search_sub_entries'] as $field) {
ExtensionManagementUtility::addToAllTCAtypes(
'pages',
Expand All @@ -36,5 +40,7 @@

ExtensionManagementUtility::addToAllTCAtypes(
'pages',
'--palette--;Search;search',
'--palette--;LLL:EXT:rmnd_headless_solr/Resources/Private/Language/locallang.xlf:pages.palettes.search;search',
);

ConfigUtility::addFlexForm('FILE:EXT:rmnd_headless_solr/Configuration/FlexForms/Config.xml');
3 changes: 0 additions & 3 deletions Configuration/TypoScript/constants.typoscript
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
@import 'EXT:solr/Configuration/TypoScript/Solr/constants.typoscript'

plugin.tx_solr {
search {
typeNum = 7385
}
suggest {
typeNum = 7384
}
Expand Down
33 changes: 12 additions & 21 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,23 @@ tt_content.list {
}
}

tx_solr_search = PAGE
tx_solr_search {
typeNum = {$plugin.tx_solr.search.typeNum}
config {
disableAllHeaderCode = 1
xhtml_cleaning = 0
admPanel = 0
additionalHeaders.10.header = Content-type: application/json
no_cache = 0
debug = 0
initialData {
10 {
fields {
solr = CONTENT
solr < lib.search
solr {
settings {
global = 1
}
}
}
}

10 < lib.search
}

tx_solr_suggest = PAGE
tx_solr_suggest < lib.headlessPage
tx_solr_suggest {
typeNum = {$plugin.tx_solr.suggest.typeNum}
config {
disableAllHeaderCode = 1
xhtml_cleaning = 0
admPanel = 0
additionalHeaders.10.header = Content-type: application/json
no_cache = 0
debug = 0
}

10 = USER
10 {
Expand Down
9 changes: 9 additions & 0 deletions Resources/Private/Language/de.locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
<file source-language="en" datatype="plaintext" product-name="headless_solr">
<header/>
<body>
<trans-unit id="flexform.config.sheet_title">
<target>Solr</target>
</trans-unit>
<trans-unit id="flexform.config.search_page">
<target>Suchseite</target>
</trans-unit>
<trans-unit id="pages.palettes.search">
<target>Suche</target>
</trans-unit>
<trans-unit id="pages.tx_headless_solr_image">
<target>Suchergebnis Bild</target>
</trans-unit>
Expand Down
9 changes: 9 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
<file source-language="en" datatype="plaintext" product-name="headless_solr">
<header/>
<body>
<trans-unit id="flexform.config.sheet_title">
<source>Solr</source>
</trans-unit>
<trans-unit id="flexform.config.search_page">
<source>Search Page</source>
</trans-unit>
<trans-unit id="pages.palettes.search">
<source>Search</source>
</trans-unit>
<trans-unit id="pages.tx_headless_solr_image">
<source>Search Result Image</source>
</trans-unit>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"require": {
"apache-solr-for-typo3/solr": "^12",
"php": "^8.2",
"remind/headless": "^3.1 | dev-develop",
"remind/headless": "^3.2 | dev-develop",
"typo3/cms-core": "^12.4"
},
"require-dev": {
Expand Down
Loading