[TYPO3-Solr] how to display tt_news items with thumbnails?
Jigal van Hemert
jigal.van.hemert at typo3.org
Wed Jan 14 09:58:28 CET 2015
Hi,
On 13/01/2015 11:22, COZANET Mathieu wrote:
> Thanks Olivier, this is a first step! (except when image doesn't
> exist, I don't find for the moment how to replace it)
For any situation where I need more complex output in the search results
(such as images, but also direct links to mail addresses, tables with
data, etcetera) I used a two level approach:
- there should not be HTML in the fields in the solr index; this will
cause problems with search result search word highlighting (solr will
wrap search words and won't look at existing markup)
- store the extra info in dynamic fields [1] in the documents in the
solr index, such as the image URL; use a field type that is not
tokenized to prevent hits for search words inside these fields
- use the renderingInstructions configuration in the search results
section to create the formatted output (including any markup of your own)
- you can now use the fields in the rendering instructions section as
markers in the template
Rendering the (thumbnail) images in the index section of the solr
configuration has the advantage that this is done during indexing and
that displaying the search results is faster. The disadvantage is that
if you remove the temporary files (images) you have to re-index your
site for the images to be recreated.
You could render the images in the rendering instructions of the search
results section in the solr configuration, but then this might slow down
the search results if the visitor gets a lot of results which do not
have a cached thumbnail image yet.
> But tt_news build thumbnails I would like to access. I can't find
> where thumbnails filenames are recorded in database :(
Thumbnails are not recorded as records and not recorded inside tt_news.
The TypoScript configuration of tt_news defines how the thumbnails must
be created. From this configuration a hash is created which is used in
the name of the cached thumbnail image. This way TYPO3 doesn't need to
recreate thumbnail images each time as long as the configuration of the
thumbnail stays the same.
> I'm a bit surprised it doesn't seem to be anyone who tried to
> associate tt_news and solr in a "user friendly" way... and asked for
> help on the web trying to do it!
There was a thread long ago in this list about creating thumbnails in
the search results. Furthermore, the requirements for each project are
different. There is enough flexibility in the configuration of solr to
create the desired output. There is never a single solution for all
cases. The configuration that is included in the solr extension is just
an example of a very basic configuration. It's a starting point for your
own configuration once you've seen that it's possible to index the news
items.
[1] https://forge.typo3.org/projects/extension-solr/wiki/Dynamic_Fields
--
Jigal van Hemert
TYPO3 CMS Active Contributor
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the TYPO3-project-solr
mailing list