Hallo, ich habe hier eine Extension umgebaut, die so einigermaßen Läuft. Nur werden Ergebnisse durcheinandergewürfelt.
Mein Ziel ist:
Begriff 1
Zubehör 1 für Begriff 1
Zubehör 2 für Begriff 1
Begriff 2
Zubehör 1 für Begriff 2
Zubehör 2 für Begriff 2
usw.
wobei $row["tx_mask_zubehoer_list"] aus einer Multselecteingabe stammt.
Hat jemand eine Idee, wie ich das hinkriege?
Mein Ziel ist:
Begriff 1
Zubehör 1 für Begriff 1
Zubehör 2 für Begriff 1
Begriff 2
Zubehör 1 für Begriff 2
Zubehör 2 für Begriff 2
usw.
wobei $row["tx_mask_zubehoer_list"] aus einer Multselecteingabe stammt.
Hat jemand eine Idee, wie ich das hinkriege?
PHP-Code:
<?php
namespace Comsolit\ComsolitSuggest\Controller;
/***************************************************************
*
* Copyright notice
*
* (c) 2015 Andres Lobacovs <info@comsolit.com>, comsolit AG
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* QueryController
*/
class QueryController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
/**
* action suggest
*
* @return void
*/
public function suggestAction() {
if($this->request->hasArgument('search')) {
$search = $this->request->getArgument('search');
$suggestions = [];
$language = $GLOBALS['TSFE']->sys_language_uid;
$field ='SQL_NO_CACHE DISTINCT tx_mask_searchkeys, tx_mask_zubehoer_list, header';
$from ='tt_content';
$where ='header LIKE '."'" . '%' . $search . '%' ."'" . '';
$groub_by = 'header';
$order_by = 'header ASC';
$limit = '';
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($field, $from, $where, $groub_by, $order_by, $limit);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)){
$suggestions[] = $row;
$field_1 = 'SQL_NO_CACHE DISTINCT tx_mask_zubehoer_tabellenzeilen.tx_mask_z_column_1';
$from_1 =' tx_mask_zubehoer_tabellenzeilen';
$where_1 = 'parentid IN('.$row["tx_mask_zubehoer_list"].')';
$groub_by_1 = '';
$order_by_1 = '';
$limit_1 = '';
$res_1 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($field_1, $from_1, $where_1, $groub_by_1, $order_by_1, $limit_1);
while($row_1 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res_1)){
$suggestions[] = $row_1;
}
}
return $this->buildJsonRepsonseFromQuery($suggestions);
}
}
private function buildJsonRepsonseFromQuery($suggestions) {
return json_encode( $this->createValueMapFromStringArray($suggestions));
}
private function createValueMapFromStringArray($array) {
$options = [];
foreach($array as $key => $value){
if(!is_int($value)) {
if(!empty($value['header'])) {
$options[$value['header']]['value'] = $value['header'];
$val_zubeboer = $value['header'];
}
if(!empty($value['tx_mask_z_column_1']))
$options[$value['tx_mask_z_column_1']]['value'] = "Zubehör für ".$val_zubeboer.": ".$value['tx_mask_z_column_1'];
}
}
return $options;
}
}
Kommentar