Actions
Bug #95238
openMetatags Keywords are not indexed by indexed_search
Status:
New
Priority:
Should have
Assignee:
-
Category:
Indexed Search
Target version:
Start date:
2021-09-16
Due date:
% Done:
0%
Estimated time:
TYPO3 Version:
11
PHP Version:
7.4
Tags:
indexed_search
Complexity:
Is Regression:
Sprint Focus:
Description
Hi, i had the problem that the indexed_search doesn't find any meta keywords on the search results.
Then i debugged this part:
https://github.com/TYPO3/typo3/blob/master/typo3/sysext/indexed_search/Classes/Indexer.php#L400-L415
if ($this->conf['index_metatags']) {
$meta = [];
$i = 0;
while ($this->embracingTags($headPart, 'meta', $dummy, $headPart, $meta[$i])) {
$i++;
}
// @todo The code below stops at first unset tag. Is that correct?
for ($i = 0; isset($meta[$i]); $i++) {
// decode HTML entities, meta tag content needs to be encoded later
$meta[$i] = GeneralUtility::get_tag_attributes($meta[$i], true);
if (stripos($meta[$i]['name'], 'keywords') !== false) {
$contentArr['keywords'] .= ',' . $this->addSpacesToKeywordList($meta[$i]['content']);
}
if (stripos($meta[$i]['name'], 'description') !== false) {
$contentArr['description'] .= ',' . $meta[$i]['content'];
}
}
The problem is, that the while only found the hreflang meta tag an then stop working.
Maybe you can change the part like this, with the new MetaTagApi ... it worked for me :)
// get keywords and description metatags
if ($this->conf['index_metatags']) {
// Get Keywords
$metaTagManager = GeneralUtility::makeInstance(MetaTagManagerRegistry::class)->getManagerForProperty('keywords');
$keywords = $metaTagManager->getProperty('keywords');
if(!empty($keywords[0]['content'])) $contentArr['keywords'] .= ',' . $this->addSpacesToKeywordList($keywords[0]['content']);
// Get Description
$metaTagManager = GeneralUtility::makeInstance(MetaTagManagerRegistry::class)->getManagerForProperty('description');
$pageDescription = $metaTagManager->getProperty('description');
if(!empty($pageDescription[0]['content'])) $contentArr['description'] .= ',' . $pageDescription[0]['content'];
}
Actions