[TYPO3-Solr] Howto to index files using solrfile and file links-elementwith path-field

Tobias Schaefer tobias.schaefer at ptb.de
Thu Nov 27 21:24:08 CET 2014


Hello Olivier,

after some debugging I could find the cause of the problem.
Solrfile is able to index files which are referenced by the Path-field. There 
is a function findFilesInSelectKeyField in classes/fileindexer/filedetector/class.tx_solr_fileindexer_filedetector_fileadmin.php 
which should find the files and should be called by the findFiles-function 
in the same class. But the findFilesInSelectKeyField-function wasn't called 
in my installation because DAM (1.3.3) is also installed. So the findFiles-function 
in classes/fileindexer/filedetector/class.tx_solr_fileindexer_filedetector_damfilelinks.php 
was called and this function only returns the list of files which are selected 
directly.
I copied the findFilesInSelectKeyField-function from class.tx_solr_fileindexer_filedetector_fileadmin.php 
to class.tx_solr_fileindexer_filedetector_damfilelinks.php and added the 
call of this function in the findFiles-function in case $damFiles['files'] 
is empty. Here's the modified code of class.tx_solr_fileindexer_filedetector_damfilelinks.php:
	protected function findFiles() {
		$damFiles = tx_dam_db::getReferencedFiles(
			'tt_content',
			$this->contentElementRecord['uid'],
			'tx_damfilelinks_filelinks'
		);
		// T. Schaefer, 2014-11-27: call findFilesInSelectKeyField if $damFiles['files'] 
is empty
		if (empty($damFiles['files'])) {
			return $this->findFilesInSelectKeyField();
		} 
		return $damFiles['files'];
	}
	
	/**
	 * T. Schaefer, 2014-11-27: copied findFilesInSelectKeyField from class.tx_solr_fileindexer_filedetector_fileadmin.php
	 * Finds files from the select_key field which points to a folder and
	 * results in listing all the files in it.
	 *
	 * @return	array	An array of files with path relative to the TYPO3 site 
root.
	 */
	protected function findFilesInSelectKeyField() {
		$files = array();

		if (!empty($this->contentElementRecord['select_key'])) {
			$typo3DocumentRoot = t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT');
			if (substr($typo3DocumentRoot, -1) != '/') {
				$typo3DocumentRoot .= '/';
			}

			$fileListPath = $this->contentElementRecord['select_key'];
			if (substr($fileListPath, -1) != '/') {
				$fileListPath .= '/';
			}

			$filesInDirectory = t3lib_div::getFilesInDir($typo3DocumentRoot . $fileListPath);

			foreach ($filesInDirectory as $file) {
				$files[] = $fileListPath . $file;
			}
		}
		return $files;
	}

Since I'm using solrfile 1.0.1 maybe this is already fixed somehow in a newer 
version, also I didn't know that there's a solrdam-extension.
We're using TYPO3 4.5 still for the next few months, so it would be great 
if you could release both extensions.

Cheers, Tobias

> Am 21.11.14 um 14:09 schrieb Tobias Schaefer:
> 
>> Hello,
>> 
>> I just found out, that solrfile doesn't index files which are not
>> linked in the File Links-element (tt_content-CType: uploads) directly
>> (field: Select Files), but through the field "Path"
>> (tt_content-select_key) (see attachment). Is there a way to get this
>> working?
>> 
>> I'm using solr 2.8.3, solrfile 1.0.1 and TYPO3 4.5.
>> 
>> Cheers, Tobias
>> 
> Please have a look at the way we detect files in the extractor section
> of EXT:solrfile. You shold be able to expand the behaviour there i
> guess.
> 
> Olivier
> 
> PS: Should we release EXT:solrfile and EXT:solrdam for those still
> using TYPO3 CMS 4.5?
> 




More information about the TYPO3-project-solr mailing list