Skip to content

Instantly share code, notes, and snippets.

@BenjaminBeck
Last active March 13, 2017 18:49
Show Gist options
  • Save BenjaminBeck/6584f5426a1d3ffbb18d to your computer and use it in GitHub Desktop.
Save BenjaminBeck/6584f5426a1d3ffbb18d to your computer and use it in GitHub Desktop.
ke_search Indexer for fluidcontent (2017: this is replaced by: https://github.com/BenjaminBeck/bdm_kesearchindexer_flux )
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['registerIndexerConfiguration'][] = 'BDM\\BdmThemeBootstrap\\Hooks\\KeSearch\\RegisterIndexerFluidcontent';
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['customIndexer'][] = 'BDM\\BdmThemeBootstrap\\Hooks\\KeSearch\\RegisterIndexerFluidcontent';
// enable:
$GLOBALS['TCA']['tx_kesearch_indexerconfig']['columns']['startingpoints_recursive']['displayCond'] .= ','.\BDM\BdmThemeBootstrap\Hooks\KeSearch\RegisterIndexerFluidcontent::$indexerType;
// disable:
$GLOBALS['TCA']['tx_kesearch_indexerconfig']['columns']['targetpid']['displayCond'] = ','.\BDM\BdmThemeBootstrap\Hooks\KeSearch\RegisterIndexerFluidcontent::$indexerType;
<?php
namespace BDM\BdmThemeBootstrap\Hooks\KeSearch;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
*
*/
class RegisterIndexerFluidcontent {
/**
* objectManager
*
* @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
*/
public $objectManager;
/**
* Custom indexer for ke_search
*
* @param array $params
* @param array $pObj
*
* @return void.
* @author Benjamin Beck <beck@beckdigitalemedien.de>
*/
public static $indexerType = 'fluidcontent';
function registerIndexerConfiguration (&$params, $pObj) {
// add item to "type" field
$newArray = array(
'Indexer for fluidcontent elements',
self::$indexerType,
\t3lib_extMgm::extRelPath( 'bdm_theme_bootstrap' ) . 'customnews-indexer-icon.gif'
);
$params['items'][] = $newArray;
}
/**
* Custom indexer for ke_search
*
* @param array $indexerConfig Configuration from TYPO3 Backend
* @param array $indexerObject Reference to indexer class.
*
* @return string Output.
* @author Benjamin Beck <beck@beckdigitalemedien.de>
*/
public function customIndexer (&$indexerConfig, &$indexerObject) {
$this->objectManager = GeneralUtility::makeInstance( '\TYPO3\CMS\Extbase\Object\ObjectManager' );
// $custom_indexer = new \custom_indexer($indexerObject);
$indexer = $this->objectManager->get('\BDM\BdmThemeBootstrap\KeSearchIndexer\TypesFluidcontent', $indexerObject);
return $indexer->startIndexing();
}
}
<?php
namespace BDM\BdmThemeBootstrap\KeSearchIndexer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
require_once ( ExtensionManagementUtility::extPath( 'ke_search' ).'Classes/indexer/types/class.tx_kesearch_indexer_types_tt_content.php');
class TypesFluidcontent extends \tx_kesearch_indexer_types_tt_content{
var $indexCTypes = array(
'fluidcontent_content'
);
public function getContentFromContentElement($ttContentRow) {
$flexform = $ttContentRow['pi_flexform'];
$flexform = strip_tags($flexform);
$flexform = html_entity_decode($flexform);
$flexform = strip_tags($flexform);
$flexform = preg_replace('/\s\s+/', ' ', $flexform);
$content = $ttContentRow['subheader'] . " " .$flexform;
$content .= parent::getContentFromContentElement($ttContentRow);
return $content;
}
}
@stauer
Copy link

stauer commented Aug 13, 2015

Hi!

Thank you for this great code example - saved me a lot of time. Unfortunately in combination with the ke_search file indexer this does not work out of the box.
You are registering the indexer inside of "customIndexer". Every customIndexer gets executed by class "tx_kesearch_indexer" (see line #162 - #171). So in case of the fileindexer also the fluidcontentindexer will run (also in case no indexer configuration was created inside of Typo3). This returns an error (invalid SQL Statement in class "tx_kesearch_indexer_types_page" - because no page results could be found with file-indexer.).

The simple solution for me was, to add the following if statement inside of class "RegisterIndexerFluidcontent":

public function customIndexer (&$indexerConfig, &$indexerObject) {
        if ($indexerConfig['type'] == self::$indexerType) {
            // START INDEXING AND RETURN RESULT
        }
        return '';
   }

This prevents executing the indexing script if it is not created / called.

Kind regards!

@verdure-tondera
Copy link

Hi BenjaminBeck, hi Stauer,

this was really useful, thanks a lot!

Greetings!

@BenjaminBeck
Copy link
Author

Hi Together,
thanks for the feedback.
@stauer - i made a github repo and added your fix: https://github.com/BenjaminBeck/bdm_kesearchindexer_flux
thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment