Commit 8ebdcb65 authored by Stefan Busemann's avatar Stefan Busemann

Merge branch 'feature/beautify-solr-results' into 'develop'

Beautify solr search

See merge request !332
parents 0a797ede 9951466a
Pipeline #8348 passed with stages
in 3 minutes and 32 seconds
# ddev apache solr recipe file
#
# To use this in your own project: Copy this file to your project's .ddev folder,
# and create the folder path .ddev/solr/conf. Then, copy the solr configuration
# files for your project to .ddev/solr/conf. E.g., using Drupal Search API Solr,
# you would copy the solr-conf/5.x/ contents into .ddev/solr/conf. The configuration
# files must be present before running `ddev start`.
version: '3.6'
services:
solr: # This is the service name used when running ddev commands accepting the --service flag
container_name: ddev-${DDEV_SITENAME}-solr # This is the name of the container. It is recommended to follow the same name convention used in the main docker-compose.yml file.
image: solr:6.6.2
restart: on-failure
solr:
container_name: ddev-${DDEV_SITENAME}-solr
image: typo3solr/ext-solr:10.0.1
restart: "no"
ports:
- 8983 # Solr is served from this port inside the container
- 8983
labels:
# These labels ensure this service is discoverable by ddev
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: $DDEV_APPROOT
com.ddev.app-url: $DDEV_URL
environment:
- VIRTUAL_HOST=$DDEV_HOSTNAME # This defines the host name the service should be accessible from. This will be sitename.ddev.local
- HTTP_EXPOSE=8983 # This defines the port the service should be accessible from at sitename.ddev.local
- VIRTUAL_HOST=$DDEV_HOSTNAME
- HTTP_EXPOSE=8983
volumes:
- "./solr:/solr-conf" # This exposes a mount to the host system `.ddev/solr-conf` directory.
- "./solr/configsets:/opt/solr/server/solr/configsets" # ext:solr configsets linking
- "./solr/mycores:/opt/solr/server/solr/mycores"
entrypoint:
- docker-entrypoint.sh
- solr-precreate
- t3o
- /solr-conf
# This links the solr service to the web service defined in the main docker-compose.yml, allowing applications running in the web service to access the solr service at sitename.ddev.local:8983
- "./solr:/opt/solr/server/solr"
web:
links:
- solr:$DDEV_HOSTNAME
......@@ -139,7 +139,7 @@ routes:
type: uri
source: 'https://typo3.org/?type=1533906435'
solr_enabled_read: true
solr_host_read: localhost
solr_host_read: solr
solr_path_read: /solr/
solr_port_read: 8983
solr_scheme_read: http
......
<?php
namespace T3o\T3orgLayout\ViewHelpers\Solr;
/*
* This file is part of a TYPO3 extension.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
class RootlineViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper
{
use \TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
protected $doktypeList = '1';
/**
* Initialize arguments.
*
* @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception
*/
public function initializeArguments()
{
$this->registerArgument('pidsRootline', 'string', 'String with UIDs of all pages from rootline', false);
}
public function render(): array
{
$rootline = [];
/** @var \ApacheSolrForTypo3\Solr\System\Solr\Document\Document $document */
$document = $this->templateVariableContainer->get('document');
if ($document['rootline']) {
/**
* Rootline looks like "4-1/2/4/7/255"
*/
$fullRootline = array_pop($document['rootline']);
$temporaryRootline = explode('-', $fullRootline);
$fullRootlineWithPidsOnly = array_pop($temporaryRootline);
$pidsRootline = explode('/', $fullRootlineWithPidsOnly);
$rootline = $this->getRootline($pidsRootline);
} elseif ($this->arguments['pidsRootline']) {
$rootline = $this->getRootline(explode('/', $this->arguments['pidsRootline']));
}
return $rootline;
}
public function getRootline(array $pidsRootline): array
{
$rootline = [];
$pageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class)
->get(\TYPO3\CMS\Frontend\Page\PageRepository::class);
// Get more information and check if page should appear
foreach ($pidsRootline as $pid) {
$page = $pageRepository->getPage((int)$pid);
if ((int)$page['hidden'] === 0 && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->doktypeList, $page['doktype'])) {
$rootline[] = $page;
}
}
return $rootline;
}
}
......@@ -34,10 +34,19 @@ plugin.tx_solr {
date = Y-m-d\TH:i:s\Z
}
media_intM = SOLR_RELATION
media_intM {
localField = fal_media
multiValue = 1
}
url.typolink.parameter >
url.typolink.parameter.stdWrap = CASE
url.typolink.parameter.stdWrap {
key.field = pid
# Security Advisories
231 = TEXT
231.value = 523
232 = TEXT
232.value = 523
233 = TEXT
......@@ -45,6 +54,7 @@ plugin.tx_solr {
234 = TEXT
234.value = 523
# Standard news articles
default = TEXT
default.value = 185
}
......
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<li class="results-entry{f:if(condition:document.isElevated, then: ' results-elevated')}"
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:t3o="http://typo3.org/ns/T3o/T3orgLayout/ViewHelpers" data-namespace-typo3-fluid="true">
<li
data-document-score="{document.score}"
data-document-id="{document.id}"
data-document-url="{document.url}"
>
<f:if condition="{document.isElevated}">
<div class="results-elevated-label">
<s:translate key="sponsored" />
</div>
</f:if>
<h5 class="results-topic">
<a href="{s:uri.result.addSearchWordList(url:document.url, searchWords:resultSet.usedQuery.keywords)}">{document.title}</a>
</h5>
<div class="row">
<div class="results-teaser">
<p class="result-content">{document.content -> f:format.crop(maxCharacters:'250')}</p>
<div class="col-12 mt-3">
<div class="card">
<div class="card-horizontal">
<div class="card-body" style="display: block;">
<h4 class="card-title">
<a href="{s:uri.result.addSearchWordList(url:document.url, searchWords:resultSet.usedQuery.keywords)}">
{document.title}
</a>
</h4>
<p class="card-text">{document.content -> f:format.crop(maxCharacters:'250')}</p>
</div>
</div>
<div class="card-footer">
<small class="text-muted">
<f:for each="{document -> t3o:solr.rootline()}" as="breadcrumb" iteration="it">
<f:if condition="{it.isFirst}">
<f:else>
<f:link.page pageUid="{breadcrumb.uid}">{breadcrumb.title}</f:link.page>
<f:if condition="{it.isLast}">
<f:else> /</f:else>
</f:if>
</f:else>
</f:if>
</f:for>
</small>
</div>
</div>
</div>
</div>
</li>
</html>
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<li class="results-entry{f:if(condition:document.isElevated, then: ' results-elevated')}"
<li class=""
data-document-score="{document.score}"
data-document-id="{document.id}"
data-document-url="{document.url}"
>
<h5 class="results-topic mb-0">
<a href="{s:uri.result.addSearchWordList(url:document.url, searchWords:resultSet.usedQuery.keywords)}"><i class="fa fa-newspaper-o"></i> {document.title}</a><br>
</h5>
<div class="news-single__categories d-inline-block small">
Published: {document.datetime_intS -> f:format.date(format:'jS F Y')}
</div>
<div class="results-teaser">
<p class="result-content">{document.content -> f:format.crop(maxCharacters:'250')}</p>
<div class="row">
<div class="col-12 mt-3">
<div class="card">
<div class="card-horizontal" style="display: flex;">
<div class="img-square-wrapper">
<a href="{s:uri.result.addSearchWordList(url:document.url, searchWords:resultSet.usedQuery.keywords)}">
<f:if condition="{document.media_intM}">
<f:then>
<f:image src="{document.media_intM.0}" width="300" />
</f:then>
<f:else>
<f:image src="EXT:t3org_layout/Resources/Public/Images/NewsDefaultImages/News_Dummy.svg" width="300" />
</f:else>
</f:if>
</a>
</div>
<div class="card-body" style="display: block;">
<h4 class="card-title">
<a href="{s:uri.result.addSearchWordList(url:document.url, searchWords:resultSet.usedQuery.keywords)}">
{document.title}
</a>
</h4>
<p class="card-text">{document.content -> f:format.crop(maxCharacters:'200')}</p>
</div>
</div>
<div class="card-footer">
<small class="text-muted">Published: {document.datetime_intS -> f:format.date(format:'jS F Y')}</small>
<f:if condition="{document.author}">
<small class="text-muted"> by {document.author}</small>
</f:if>
</div>
</div>
</div>
</div>
</li>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment