Closed mikestreety closed 3 years ago
Unfortunately this behaviour is "by design": ke_search indexes content directly from the database without any further processing. So no placeholders get replaced as it would happen in the TYPO3 frontend.
A workaround for this would be to add a hook which processes the content before storing it into the index and replace the placeholders there.
You could use the "modifyContentFromContentElement" hook. You can find an example in the ke_search_hooks extension (https://github.com/teaminmedias-pluswerk/ke_search_hooks).
Thank you!
As a follow up to this, I managed to resolve this last week. Just putting a note here in case anyone ends up here from searching.
In ext_localconf.php
load the class:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyContentFromContentElement'][] =
\LiquidLight\KeSearch\Hook\ProcessPlaceholderText::class;
And in your class file:
<?php
namespace LiquidLight\KeSearch\Hook;
use TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlViewHelper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
class ProcessPlaceholderText extends HtmlViewHelper {
public function modifyContentFromContentElement(string &$bodytext, array $ttContentRow, $pageIndexer) {
/**
* Store the page text after processing
*
* E.g. replace ###COMPANY_NAME### with the name of the company
*/
if (TYPO3_MODE === 'BE') {
self::simulateFrontendEnvironment();
}
$contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
$contentObject->start([]);
$bodytext = $contentObject->parseFunc($bodytext, [], '< lib.parseFunc');
}
}
Hey,
Thank you so much for the great search plugin - works much better (and is a lot clearer) then the indexed search.
One thing I've noticed (and apologies if the terminology isn't right) but it doesn't seem to render placeholders in the abstract/snippet?
In the
setup
typoscript, you can declare aconstants
block. This can then be used inside RTE.E.g.
When in TYPO3, you can then enter
###COMPANY_NAME###
and, when rendering on the frontend, this will be replaced withmikestreety
.The KE Search caches the
###COMPANY_NAME###
instead of the value in the abstract. Is this possible to resolve?Thanks again for the awesome work - and again, apologies if I have slightly misunderstood or got terminology wrong!