Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Use FLUID templating for your TYPO3 search

794 views

Published on

Introduction how to use FLUID templating for your TYPO3 solr search

Published in: Engineering
  • Be the first to comment

Use FLUID templating for your TYPO3 search

  1. 1. EXT:solr and FLUID: Use FLUID templating for your search 1
  2. 2. EXT:solr short overview Search Extension for TYPO3
 Started in 2009 (pi based) by Ingo Renner
 Code hosted on github: https://github.com/TYPO3-Solr/ext-solr
 Financed by dkd and partners Addons available: * EXT:solrfal File indexing from FAL for TYPO3 2
  3. 3. About me 3 Timo Hund 33 years old @TYPO3 since: 2003
 @Apache Solr since: 2009
 @dkd since: 2015
 
 Email: timo.hund@dkd.de Xing: https://www.xing.com/profile/Timo_Hund2
 Github: https://github.com/timohund Twitter: @TimoHund

  4. 4. Our team 4 Olivier Dobberkau Timo Hund Ingo Renner Markus Friedrich Thomas Janke Development Development Development Management Management Rafael Kähm Development
  5. 5. Useful links • Blogpost of solrfuid 1.0:
 http://www.typo3-solr.com/en/blog/details/news/ solrfluid_100_has_been_released/
 • Customizing boilerplate extension:
 https://github.com/TYPO3-Solr/ext-solrfluidexample
 • Slack channel:
 https://typo3.slack.com/messages/ext-solr
 • Documentation:
 https://www.typo3-solr.com/en/solr-for-typo3/documentation/
 
 5
  6. 6. Overview Available frontend plugins and what they do… 6
  7. 7. Searchbox 7 • Renders the search form only • Can be used as entry point from outside to start a search • Triggers SearchController::formAction
  8. 8. Searchbox 8
  9. 9. Frequent searches 9 • Renders frequent searches from the statistics • Triggers SearchController::frequentlySearchedAction()
  10. 10. Frequent searches 10
  11. 11. Search resultlist 11 • Renders the search results (Form, Results, AdditionalComponents) • Triggers SearchController::resultsAction()
  12. 12. Search resultlist 12
  13. 13. Concepts & Structure Concepts & Structure of the FLUID templating in EXT:solr 13(c) by Timo Hund & dkd Internet Service GmbH (Copy for internal use only).
  14. 14. Marker based templating • Default before EXT:solr 7.0.0 
 (FLUID was not available when EXT:solr was started)
 • Extended marker concept of the core (loops, if/else, …), innovative at that time… • Limitations • No Partials • Limited ViewHelpers • Additional learning • Implicite loading of JS and CSS files • Spreathed logic for url generation • Templateengine was part of the extension => more maintenance • PI based (No MVC) 14
  15. 15. FLUID based templating • Since 7.0.0 part of EXT:solr • Brings • Domain model for Results/Facets/Sorting/… • Extbase controllers (MVC & DDD Pattern) • Default fluid layouts/partials and templates • ViewHelpers needed for search • Unified url generation • Performance improvements 15
  16. 16. 16 What happens when the User hits „Search“?
  17. 17. 17 Browser HTTP GET HTTP GET JsonHtml
  18. 18. 18 Browser HTTP GET HTTP GET JsonHtml
  19. 19. 19 • Simplified sequence diagram • The searchAction passes the SearchResultSet to the view • The SearchResultSet can be used to access results, facets,…
  20. 20. 20 Browser HTTP GET HTTP GET JsonHtml
  21. 21. Example query and response http://8.7.local.typo3.org:8083/solr/core_en/select?fl=*,score &fq=siteHash:“9e9d76a598c63d4ff578fea5c5254c27d9554fc6" &fq={typo3access}-1,0 &debugQuery=true &echoParams=all &spellcheck.maxCollationTries=1 &qf=content^40.0 title^5.0 keywords^2.0 tagsH1^5.0 tagsH2H3^3.0 tagsH4H5H6^2.0 tagsInline&hl=true &hl.fragsize=200 &hl.fl=content &facet=true &facet.mincount=1 &facet.limit=100&facet.field=type &facet.field=keywords_stringM &facet.query=created:[NOW/DAY-7DAYS TO *] &facet.query=created:[NOW/DAY-1MONTH TO NOW/DAY-7DAYS]
 &facet.query=created:[NOW/DAY-6MONTHS TO NOW/DAY-1MONTH]
 &facet.query=created:[NOW/DAY-1YEAR TO NOW/DAY-6MONTHS]
 &facet.query=created:[* TO NOW/DAY-1YEAR]
 &facet.sort=count
 &wt=json
 &json.nl=map&q=cms&start=0&rows=10 21 EXT:solr builds this query for your and queries the 
 Apache Solr Server
  22. 22. Example query and response 22 Apache Solr delivers a json/xml response that contains facets, results … EXT:solr creates the SearchResultSet from that.
 
 The SearchResultSet can be used to access all needed data for the output
  23. 23. Search resultlist 23 FormSorting Facet Area Results Last Searches Frequent Searches
  24. 24. Get domain objects from SearchResultSet 24
  25. 25. 25 Example:
 <f:for each="{resultSet.searchResults}" as="result">
 <h1>{result.title}</h1>
 </f:for>
 Get domain objects from SearchResultSet
  26. 26. Example: <f:for each="{resultSet.facets.available}" as="facet">
 <h1>{facet.label}</h1> <f:for each="{facet.options}" as=“option“> {option.label} </f:for>
 </f:for>
 26 options, hierarchy, queryGroup numericRange & dateRange Get domain objects from SearchResultSet
  27. 27. Get domain objects from SearchResultSet 27 Example:
 <f:if condition="{resultSet.sortings.hasSelected}"> <p>{resultSet.sortings.selected.label}</p> </f:if>

  28. 28. Get domain objects from SearchResultSet 28 Example: <p>{resultSet.usedSearchRequest.page}</p> 

  29. 29. FLUID templates overview 29
  30. 30. Search resultlist 30 FormSorting Facet Area Results Last Searches Frequent Searches • Rendering starts in: EXT:solr/Resources/Private/Templates/Search/Results.html
  31. 31. Search results How to the search results are rendered 31
  32. 32. Search resultlist 32 Results
  33. 33. Search resultlist <f:if condition="{hasSearched}">
 <f:if condition="{resultSet.usedSearch.numberOfResults}">
 <f:render partial="Result/PerPage" section="PerPage" arguments="{resultSet: resultSet}" />
 </f:if>
 <s:widget.resultPaginate resultSet="{resultSet}">
 <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>
 </ol>
 </s:widget.resultPaginate> </f:if>
 33 Every document is passed to the Results/Document partial to render the search result • You can use: EXT:solr/Resources/Private/Partials/Result/Document.html and adapt it to your needs.
  34. 34. Faceting What are facets and how to configure them? 34
  35. 35. Faceting 35 Facet Area
  36. 36. Faceting • Facets help the user to „narrow down“ or „filter“ the results, to find what he is looking for.
 • Based on a solr field
 • Configured with TypoScript
 • Have different types • Option • Query Group • Hierarchical • Date Range • Numeric Range
 
 
 
 36
  37. 37. Example Content type facet of a page:
 plugin.tx_solr.search.faceting.facets {
 type {
 label = Content Type
 field = type type = options* }
 } *type „options“ is default 37
  38. 38. Available option based facets 38 options hierarchy queryGroup Flat list of selectable options Nested tree of options Flat list based on solr querys Example: EXT:solr/Configuration/TypoScript/Examples/Facets/QueryGroup/setup.txt Example: EXT:solr/Configuration/TypoScript/Examples/Facets/Hierarchy/setup.txt Default Partial: EXT:solr/Resources/Private/Partials/Facets/Options.html Default Partial: EXT:solr/Resources/Private/Partials/Facets/Hierarchy.html Default Partial: EXT:solr/Resources/Private/Partials/Facets/Options.html
  39. 39. Available range based facets 39 numericRange dateRange Numeric range between a
 min and max value Date range between a start and end date Example: EXT:solr/Configuration/TypoScript/Examples/Facets/NumericRange/setup.txt Example: EXT:solr/Configuration/TypoScript/Examples/Facets/DateRange/setup.txt Default Partial: EXT:solr/Resources/Private/Partials/Facets/NumericRange.html Default Partial: EXT:solr/Resources/Private/Partials/Facets/DateRange.html
  40. 40. Customizing Use custom Templates / Partials or ViewHelpers 40
  41. 41. Resources • EXT:solrfluidexample - example extension that shows how to use: • Custom Templates • Custom Translations • Custom ViewHelpers • https://github.com/TYPO3-Solr/ext-solrfluidexample
 • EXT:solr documentation: • https://docs.typo3.org/typo3cms/extensions/solr/
 41
  42. 42. Custom templates Use templates for a custom extension 42
  43. 43. Using FLUID rootPaths • FLUID supports fallbacks:
 plugin.tx_solr.view {
 partialRootPaths {
 0 = EXT:solr/Resources/Private/Partials/
 100 = EXT:myextension/Resources/Private/Partials/
 }
 templateRootPaths {
 0 = EXT:solr/Resources/Private/Templates/
 100 = EXT:myextension/Resources/Private/Templates/
 }
 } • See also: https://www.fiedomedia.de/news/artikel/template-fallbacks-in-typo3-fluid/
 
 43
  44. 44. Custom facet partials How to render facets in a custom partials 44
  45. 45. Use custom facet partial Change the partialName to „Custom“ in TypoScript:
 plugin.tx_solr.search.faceting.facets { category { label = Category field = keywords_stringM type = options partialName = Custom }
 }
 
 Copy the default partial „Options.html“ to 
 „Custom.html“
 
 Use the core ViewHelper to make the option uppercase:
 {option.label} => <f:format.case value="{option.label}" mode="upper"/> 45
  46. 46. Thanks! 46 • To all EB partners ! • Thanks to all contributors! All previous partners can be found here: http://www.typo3-solr.com/en/sponsors/our-sponsors/
  47. 47. Questions & Answers 47
  48. 48. Excited and what to learn more? 48 Join the next Apache Solr for TYPO3 Training or book an exclusive training for your company! Get a 15% camp discount when you book a workshop in the next 10 days!
  49. 49. Do you want to support 
 Apache Solr for TYPO3? 49 Become an EB partner and sponsor the development/ maintenance & support of Apache Solr for TYPO3

×