Code example
This adds a new indexer configuration type to the ke_search extension.
With this configuration fluidcontent elements can be indexed.
- Description
- ke_search Indexer for fluidcontent (2017: this is replaced by: https://github.com/BenjaminBeck/bdm_kesearchindexer_flux )
- Author
- BenjaminBeck
- Creation date
- Extensions
- FluidTYPO3.Fluidcontent
- Tags
- Content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $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'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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 <[email protected]> | |
| */ | |
| 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 <[email protected]> | |
| */ | |
| 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(); | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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; | |
| } | |
| } |