Bug #81828
closedIndexed Search and news
0%
Description
Hello guys !
I had some bug with indexed_search trying to reference news from the well known Georg Ringer extension.
I wanted to know if these problem was already seen by any of you or if some configuration tips can fix it, for the moment, i'm using some personal fix using overloading. But it could be cool to have a more elegant solution, maybe modifying the core can also be a good idea but i'm not enought skilled to give my opinion about it.
Problem 1¶
The first problem was caused by fluid on the Administration/Pages template.
This piece of code caused the error :
<f:if condition="{data.cHashParams}">
<f:for each="{data.cHashParams}" as="value" key="key">
{key}={value}<br>
</f:for>
</f:if>
The problem was that the "cHashParams" variable wasn't a simple array of string, it is an array of string and there is an element of the array that is a sub-array. So the view gave me an error trying to display an array with {value}
My solution was to create a ViewHelper to check if the variable is an array or not and to create a recursive Partial.
<f:if condition="{data.cHashParams}">
<f:for each="{data.cHashParams}" as="value" key="key">
<f:if condition="{e:isIterable(var: value)}" >
<f:then>
<f:render partial="cHashResult" arguments="{prefix: key, cHashParams: value}"/>
</f:then>
<f:else>
{key}={value}<br>
</f:else>
</f:if>
</f:for>
</f:if>
The partial :
{namespace e=Emagineurs\EMagineurs\ViewHelpers}
<f:for each="{cHashParams}" as="value" key="key">
<f:if condition="{e:isIterable(var: value)}" >
<f:then>
<f:render partial="cHashResult" arguments="{prefix: '[{key}]', cHashParams: value}" />
</f:then>
<f:else>
{prefix}[{key}]={value}<br>
</f:else>
</f:if>
</f:for>
Problem 2¶
The problem was in the SearchController, the function linkPage() that generate the link for a search result wasn't correctly generate the links for news.
It was caused by the fact that the "pageUid" param wasn't my page to display news detail but the page id of the record storage page. For me, the record storage page is a folder so the generated link was an empty string.
To fix it, i overloaded the SearchController with the following :
class SearchController extends \TYPO3\CMS\IndexedSearch\Controller\SearchController
{
/**
* Links the $linkText to page $pageUid
*
* @param int $pageUid Page id
* @param string $linkText Title to link (must already be escaped for HTML output)
* @param array $row Result row
* @param array $markUpSwParams Additional parameters for marking up search words
* @return string <A> tag wrapped title string.
* @todo make use of the UriBuilder
*/
protected function linkPage($pageUid, $linkText, $row = [], $markUpSwParams = [])
{
$urlParameters = (array)unserialize($row['cHashParams']);
return parent::linkPage($urlParameters['id'], $linkText, $row, $markUpSwParams);
}
}
My indexed_search conf is the following :
Files
Updated by Benni Mack over 4 years ago
- Status changed from New to Closed
cHash calculation is now "Built-in" and the option has been removed. The issue should be solved with TYPO3 v9 / v10 - feel free to re-open the issue if you think the issue persists in current versions.