File tree Expand file tree Collapse file tree
Classes/Flowpack/SearchPlugin/TypoScriptObjects Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+ namespace Flowpack \SearchPlugin \TypoScriptObjects ;
3+
4+
5+ /* *
6+ * This script belongs to the TYPO3 Flow package "Flowpack.SearchPlugin.TypoScriptObjects". *
7+ * *
8+ * It is free software; you can redistribute it and/or modify it under *
9+ * the terms of the GNU Lesser General Public License, either version 3 *
10+ * of the License, or (at your option) any later version. *
11+ * *
12+ * The TYPO3 project - inspiring people to share! *
13+ * */
14+
15+ use TYPO3 \Flow \Annotations as Flow ;
16+ use TYPO3 \TypoScript \TypoScriptObjects \AbstractTypoScriptObject ;
17+
18+ /**
19+ * Class CanRenderImplementation
20+ *
21+ */
22+ class CanRenderImplementation extends AbstractTypoScriptObject {
23+
24+ /**
25+ * TypoScript Type which shall be rendered
26+ * @return string
27+ */
28+ public function getType () {
29+ return $ this ->tsValue ('type ' );
30+ }
31+
32+ /**
33+ * Evaluate this TypoScript object and return the result
34+ *
35+ * @return mixed
36+ */
37+ public function evaluate () {
38+ return $ this ->tsRuntime ->canRender ('/type< ' . $ this ->getType () . '> ' );
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ < form action ="" method ="GET ">
2+ < input type ="text " name ="search " value ="{searchWord} " />
3+ < button type ="submit "> Send</ button >
4+ </ form >
Original file line number Diff line number Diff line change 11{namespace neos=TYPO3\Neos\ViewHelpers}
22{namespace ts=TYPO3\TypoScript\ViewHelpers}
3- SEARCs {searchWord}
4- < div class ="search-results ">
5- < f:if condition ="{searchResults -> f:count()} ">
6- < dl >
7- < f:for each ="{searchResults} " as ="searchResult ">
8- < f:alias map ="{documentNode: '{ts:render(path: \'searchResultDocument\', context: {searchResult: \'{searchResult}\'})}'} ">
9- < f:if condition ="{documentNode} ">
10- < dt >
11- < neos:link .node node ="{documentNode} "> {documentNode.fullLabel}</ neos:link .node>
12- </ dt >
13- < dd >
14- < ts:render path ="searchResultContentRenderer " context ="{node: searchResult} " />
15- </ dd >
16- </ f:if >
17- </ f:alias >
18- </ f:for >
19- </ dl >
20- </ f:if >
21- </ div >
3+
4+ {searchForm -> f:format.raw()}
5+
6+ Showing {searchResults -> f:count()} of {totalSearchResults} results
7+
8+ {searchResultRenderer -> f:format.raw()}
Original file line number Diff line number Diff line change 1+ {namespace neos=TYPO3\Neos\ViewHelpers}
2+
3+ < b > < neos:link .node node ="{node} ">
4+ {title}
5+ </ neos:link .node> </ b > < br />
6+
7+ < f:if condition ="{description} ">
8+ {description}
9+ </ f:if >
Original file line number Diff line number Diff line change 1+ prototype(Flowpack.SearchPlugin:SingleResult) < prototype(TYPO3.TypoScript:Case) {
2+ default {
3+ condition = Flowpack.SearchPlugin:CanRender {
4+ type = ${node.nodeType.name + 'SearchResult'}
5+ }
6+ condition = TRUE
7+ type = ${node.nodeType.name + 'SearchResult'}
8+ }
9+
10+ fallback {
11+ condition = TRUE
12+ type = 'TYPO3.Neos:DocumentSearchResult'
13+ }
14+ }
15+
16+ prototype(TYPO3.Neos:DocumentSearchResult) < prototype(TYPO3.TypoScript:Template) {
17+ templatePath = 'resource://Flowpack.SearchPlugin/Private/Templates/SearchResult/DocumentSearchResult.html'
18+ node = ${node}
19+
20+ title = ${q(node).property('title')}
21+ description = ''
22+ }
23+
24+ prototype(TYPO3.Neos.NodeTypes:PageSearchResult) < prototype(TYPO3.Neos:DocumentSearchResult)
25+
26+
27+ prototype(TYPO3.NeosDemoTypo3Org:ChapterSearchResult) < prototype(TYPO3.Neos:DocumentSearchResult) {
28+ description = ${q(node).property('chapterDescription')}
29+ }
Original file line number Diff line number Diff line change 1- prototype(Flowpack.Search:Search) {
2- searchResults = ${Search.query(site).fulltext(request.arguments.search).execute()}
3- searchWord = "foo"
1+ prototype(Flowpack.SearchPlugin:CanRender).@class = 'Flowpack\\SearchPlugin\\TypoScriptObjects\\CanRenderImplementation'
42
5- searchResultDocument = ${searchResult ? q(searchResult).closest('[instanceof TYPO3.Neos:Document]').get(0) : null}
6-
7- searchResultContentRenderer = ${String.crop(String.stripTags(q(node).property('title') + q(node).property('text')), 300) + '...'}
8-
9- @cache {
10- mode = 'uncached'
11- context {
12- 1 = 'site'
13- }
14- }
15- }
3+ include: SearchPlugin.ts2
4+ include: ResultRendering.ts2
Original file line number Diff line number Diff line change 1+
2+ prototype(Flowpack.SearchPlugin:Search) {
3+
4+ // we store the search results in the TypoScript context, so that they bubble through the nested elements like the searchResultRenderer
5+ @override.searchResults = ${this.searchQuery.execute()}
6+
7+
8+ searchQuery = ${Search.query(site).fulltext(request.arguments.search)}
9+
10+ totalSearchResults = ${this.searchQuery.count()}
11+ searchResults = ${searchResults}
12+
13+ searchForm = Flowpack.SearchPlugin:Search.Form
14+
15+ searchResultRenderer = TYPO3.TypoScript:Collection {
16+ collection = ${searchResults}
17+ itemRenderer = Flowpack.SearchPlugin:SingleResult
18+ itemName = 'node'
19+ }
20+
21+ searchResultRenderer.@process.wrap = ${'<ul>' + value + '</ul>'}
22+ prototype(Flowpack.SearchPlugin:SingleResult).@process.wrap = ${'<li>' + value + '</li>'}
23+
24+ @cache {
25+ mode = 'uncached'
26+ context {
27+ 1 = 'site'
28+ 2 = 'node'
29+ }
30+ }
31+ }
32+
33+
34+ prototype(Flowpack.SearchPlugin:Search.Form) < prototype(TYPO3.TypoScript:Template) {
35+ templatePath = 'resource://Flowpack.SearchPlugin/Private/Templates/NodeTypes/Search.Form.Html'
36+ searchWord = ${request.arguments.search}
37+ }
38+
You can’t perform that action at this time.
0 commit comments