Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
services
t3o sites
typo3.org
typo3.org
Commits
c40e3cb3
Commit
c40e3cb3
authored
Feb 15, 2021
by
Stefan Busemann
Browse files
Merge branch 'feature/add-facets' into 'develop'
Add facets See merge request
!422
parents
a5864f40
0874d3bc
Pipeline
#10341
passed with stages
in 6 minutes and 32 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extensions/t3org_layout/Classes/Slot/SolrSlot.php
0 → 100644
View file @
c40e3cb3
<?php
namespace
T3o\T3orgLayout\Slot
;
class
SolrSlot
{
public
function
addResultsWithoutFacets
(
array
$values
):
array
{
if
(
$values
[
'resultSet'
]
->
getUsedQuery
())
{
$filterQueries
=
$values
[
'resultSet'
]
->
getUsedQuery
()
->
getFilterQueries
();
unset
(
$filterQueries
[
'type'
]);
$values
[
'resultSet'
]
->
getUsedQuery
()
->
setFilterQueries
(
$filterQueries
);
$allValuesFoundWithoutFacet
=
(
int
)
$values
[
'resultSet'
]
->
getUsedSearch
()
->
search
(
$values
[
'resultSet'
]
->
getUsedQuery
())
->
getParsedData
()
->
response
->
numFound
;
$values
[
'allResultCountWithoutFacets'
]
=
$values
[
'resultSet'
]
->
getAllResultCount
();
if
(
$allValuesFoundWithoutFacet
>
0
)
{
$values
[
'allResultCountWithoutFacets'
]
=
$allValuesFoundWithoutFacet
;
}
}
return
[
$values
];
}
}
extensions/t3org_layout/Configuration/TypoScript/Ext/Solr.typoscript
View file @
c40e3cb3
...
...
@@ -3,11 +3,9 @@ plugin.tx_solr {
templateRootPaths {
10 = EXT:t3org_layout/Resources/Private/Templates/Solr
}
partialRootPaths {
10 = EXT:t3org_layout/Resources/Private/Partials/Solr
}
layoutRootPaths {
10 = EXT:t3org_layout/Resources/Private/Layouts/Solr
}
...
...
@@ -25,6 +23,38 @@ plugin.tx_solr {
}
boostQuery = (type:tx_sfeventmgt_domain_model_event)^200
}
faceting >
faceting = 1
faceting {
keepAllFacetsOnSelection = 1
facets {
type {
field = type
label = Type
partialName = Tabs
renderingInstruction = CASE
renderingInstruction {
key.field = optionValue
pages = TEXT
pages {
value = Pages
}
tx_news_domain_model_news = TEXT
tx_news_domain_model_news {
value = News
}
tx_sfeventmgt_domain_model_event = TEXT
tx_sfeventmgt_domain_model_event {
value = Events
}
}
}
}
}
}
index {
...
...
extensions/t3org_layout/Resources/Private/Partials/Solr/Facets/Tabs.html
0 → 100644
View file @
c40e3cb3
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xmlns:f=
"http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
data-namespace-typo3-fluid=
"true"
>
<f:for
each=
"{facet.options}"
as=
"option"
iteration=
"iteration"
>
<li
class=
"nav-item"
>
<a
class=
"facet solr-ajaxified nav-link{f:if(condition:option.selected,then: ' active')}"
href=
"{s:uri.facet.setFacetItem(facet: facet, facetItem: option)}"
>
{option.label}
<span
class=
"badge badge-dark"
>
{option.documentCount}
</span>
</a>
</li>
</f:for>
</html>
extensions/t3org_layout/Resources/Private/Partials/Solr/Result/Facets.html
0 → 100644
View file @
c40e3cb3
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xmlns:f=
"http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
xmlns:s=
"http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers"
>
<f:section
name=
"Facets"
>
<s:facet.area.group
groupName=
"main"
facets=
"{resultSet.facets.available}"
>
<f:for
each=
"{areaFacets}"
as=
"facet"
>
<f:render
partial=
"Facets/{facet.partialName}"
arguments=
"{resultSet:resultSet, facet:facet}"
/>
</f:for>
</s:facet.area.group>
</f:section>
extensions/t3org_layout/Resources/Private/Templates/Solr/Search/Results.html
View file @
c40e3cb3
...
...
@@ -49,8 +49,32 @@
</f:if>
<f:if
condition=
"{resultSet.hasSearched}"
>
<s:widget.resultPaginate
resultSet=
"{resultSet}"
configuration=
"{templatePath:'EXT:t3org_layout/Resources/Private/Templates/ViewHelpers/Widget/ResultPaginate/Index.html'}"
>
<ol
start=
"{pagination.displayRangeStart}"
class=
"results-list"
>
<div
class=
"container search-filter mb-4"
>
<div
class=
"row"
>
<div
class=
"col-12"
>
<f:variable
name=
"facetUsed"
value=
"0"
/>
<f:for
each=
"{resultSet.facets}"
as=
"facet"
>
<f:if
condition=
"{facet.isUsed}"
>
<f:variable
name=
"facetUsed"
value=
"1"
/>
</f:if>
</f:for>
<ul
class=
"nav nav-tabs"
>
<li
class=
"nav-item"
>
<a
href=
"{s:uri.facet.removeAllFacets()}"
class=
"nav-link{f:if(condition:'{facetUsed}', else:' active')}"
"
>
All
<span
class=
"badge badge-dark"
>
{allResultCountWithoutFacets}
</span>
</a>
</li>
<f:if
condition=
"{resultSet.hasSearched}"
>
<f:if
condition=
"{resultSet.usedSearchRequest.contextTypoScriptConfiguration.searchFaceting}"
>
<f:render
partial=
"Result/Facets"
section=
"Facets"
arguments=
"{resultSet:resultSet}"
/>
</f:if>
</f:if>
</ul>
</div>
</div>
<s:widget.resultPaginate
resultSet=
"{resultSet}"
configuration=
"{insertAbove: 0, templatePath:'EXT:t3org_layout/Resources/Private/Templates/ViewHelpers/Widget/ResultPaginate/Index.html'}"
>
<ol
start=
"{pagination.displayRangeStart}"
class=
"results-list"
>
<f:for
each=
"{documents}"
as=
"document"
>
<f:render
partial=
"Result/Document"
section=
"Document"
arguments=
"{resultSet:resultSet, document:document}"
/>
</f:for>
...
...
extensions/t3org_layout/ext_localconf.php
View file @
c40e3cb3
...
...
@@ -14,3 +14,12 @@ $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['SolrSuggest'] = \T3o\T3orgLayo
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'EXT'
][
'news'
][
'classes'
][
'Domain/Model/News'
][]
=
't3org_layout'
;
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'SC_OPTIONS'
][
't3lib/class.t3lib_tcemain.php'
][
'processDatamapClass'
][
't3org_layout'
]
=
\
T3o\T3orgLayout\Hook\DataHandlerHook
::
class
;
// Solr slot
$signalSlotDispatcher
=
\
TYPO3\CMS\Core\Utility\GeneralUtility
::
makeInstance
(
\
TYPO3\CMS\Extbase\SignalSlot\Dispatcher
::
class
);
$signalSlotDispatcher
->
connect
(
\
ApacheSolrForTypo3\Solr\Controller\SearchController
::
class
,
'resultsAction'
,
\
T3o\T3orgLayout\Slot\SolrSlot
::
class
,
'addResultsWithoutFacets'
);
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment