Skip to content

Commit ce2ca5d

Browse files
author
eike
committed
[FEATURE] allow to select one collection via typoscript
Related: #2
1 parent d4d0cd7 commit ce2ca5d

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

Classes/Controller/SearchController.php

+10
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,20 @@ public function indexAction()
8484
*/
8585
public function searchAction(Demand $demand, $page = 1)
8686
{
87+
/** @var \TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility $configurationUtility */
88+
$configurationUtility = $this->objectManager->get('TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility');
89+
$extensionConfiguration = $configurationUtility->getCurrentConfiguration('yacy');
90+
if($extensionConfiguration['debug']['value'] === '1'){
91+
$this->view->assign('query', $demand->getRequestUrl());
92+
}
8793
$itemsPerPage = 10;
8894

8995
$demand->setStartRecord($itemsPerPage * ($page - 1));
9096

97+
if($this->settings['collection'] !== '' && strpos($demand->getQuery(),'collection') === false) {
98+
$demand->setQuery($demand->getQuery().'+collection'.':'.$this->settings['collection']);
99+
}
100+
91101
$results = $this->searchRepository->findDemanded($demand);
92102

93103
$resultsCount = $this->searchRepository->countAllRequested($demand);

Configuration/TypoScript/constants.txt

+2
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ plugin.tx_yacy {
2323
interface = yacysearch.rss
2424
# cat=plugin.tx_yacy//e; type=string; label=PID of the result page
2525
resultPage =
26+
# cat=plugin.tx_yacy//f; type=string; label=Collection you want to use
27+
collection =
2628
}
2729
}

Configuration/TypoScript/setup.txt

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ plugin.tx_yacy {
1818
protocol = {$plugin.tx_yacy.settings.protocol}
1919
interface = {$plugin.tx_yacy.settings.interface}
2020
resultPage = {$plugin.tx_yacy.settings.resultPage}
21+
collection = {$plugin.tx_yacy.settings.collection}
2122
}
2223
}
2324

Resources/Private/Templates/Search/Search.html

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
<f:render partial="Search/SearchForm" arguments="{demand:demand}" section="main" />
77
</div>
88
</section>
9+
<f:if condition="{query}">
10+
<div>{query}</div>
11+
</f:if>
912
<f:if condition="{results}">
1013
<div>
1114
{resultsCount} <f:translate key="yacy.resultsCount"> results found</f:translate>
1215
</div>
1316
<br>
17+
1418
<f:for each="{results}" as="result">
1519
<f:link.external uri="{result.link}"><b>{result.title}</b></f:link.external> <br>
1620
<f:link.external uri="{result.link}">{result.link}</f:link.external>
@@ -33,7 +37,7 @@
3337
</f:link.action>
3438
</f:if>
3539
<f:for each="{pagination.pages}" as="item">
36-
<f:link.action action="search" arguments="{page: item.text, demand: demand}"
40+
<f:link.action action="search" arguments="{page: item.text, demand: demand}"
3741
class="paginator-page {f:if(condition: '{0:pagination.current} == {0:item.text}',then: ' active', else: '')}">
3842
{item.text}
3943
</f:link.action>
@@ -49,7 +53,7 @@
4953
</f:link.action>
5054
</f:if>
5155
</f:if>
52-
56+
5357
<br class="clear-all">
5458
</div>
55-
</f:section>
59+
</f:section>

ext_conf_template.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# cat=basic/enable; type=boolean; label=Debug mode
2+
debug = 0

0 commit comments

Comments
 (0)