Project

General

Profile

Actions

Bug #81828

closed

Indexed Search and news

Added by Le Sommer Léo Robin almost 7 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Could have
Assignee:
-
Category:
Indexed Search
Start date:
2017-07-10
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.1
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

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 :
indexed_search conf


Files

Capture1.PNG (40.2 KB) Capture1.PNG indexed_search conf Le Sommer Léo Robin, 2017-07-10 14:09
Actions #1

Updated by Benni Mack about 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.

Actions

Also available in: Atom PDF