[TYPO3-core] RFC #6872: Add suggest-like feature to TCEforms

Benjamin Mack benni at typo3.org
Tue Jun 2 16:33:19 CEST 2009


Hey all,

finally a new version of this patch has arrived. I did some major 
overhauls, added the use of the autoloader, and except for some small 
things (usability is not perfect, but not really possible to fix with 
current TCEforms without a major change there) I like it, and it got my 
+1 after reading and testing. I will also write a patch for 4.2 once 
it's ready to commit, as I want to use it for one client of mine.

However, as this patch has now changed a lot from the beginning, I 
request that Andreas Wolf at least looks over the code once more and 
maybe gives it a spin, and at least one more (better two) person does a 
profound code-review and testing. Maybe

Thanks a lot!

=== Documentation (preliminary)

The suggest-feature is implemented as a wizard to TCEforms.

It can be added like any other wizard, basically by modifying the TCA. 
As an example, I will use the "storage_pid" field of the "pages" table.

To get the suggest-feature up and running, please add this to your 
extTables.php.

$TCA['pages']['columns']['storage_pid']['config']['wizards']['suggest'] 
= array('type' => 'suggest');

The suggest field should now show up when editing page properties. When 
typing something in (at least 2-3 characters), there is a list (sorted 
alphabetically) of max. 10 items that can be selected.

The tables that are queried to be shown up are the ones used in 
$TCA['pages']['columns']['storage_pid']['config']['allowed']

The following options are available to be set by TCA, and then 
overridden the following way (the last one takes precedence of the former):

// TCA
1. 
$TCA[$table]["columns"][$field]["config"]["wizards"]["suggest"]["default"]
2. 
$TCA[$table]["columns"][$field]["config"]["wizards"]["suggest"][$queryTable]

// TSconfig:
3. TCEMAIN.default.suggest
4. TCEMAIN.$queryTable.suggest
5. TCEFORM.$table.$field.suggest.default
6. TCEFORM.$table.$field.suggest.$queryTable

For the storage_pid example, this looks like the following (table=pages, 
field=storage_pid, queryTable=pages):

$TCA["pages"]["columns"][$field]["config"]["wizards"]["suggest"]["default"]
$TCA["pages"]["columns"][$field]["config"]["wizards"]["suggest"]["pages"]
TCEMAIN.default.suggest
TCEMAIN.pages.suggest
TCEFORM.pages.storage_pid.suggest.default
TCEFORM.pages.storage_pid.suggest.pages

The following options are avilable:

TCEMAIN.default.suggest {
	# (intList) Limit the search to certain PIDs (and their subpages)
	pidList = 1,2,3,45

	# (int) the number of levels of the subpages of the pidList that should 
be used as well
	pidDepth = 4

	# (int+) max. numbers of characters to display when a path element is 
too long
	maxPathTitleLength = 30

	# (bool) whether to do a LIKE=%mystring% (searchWholePhrase = 1) or a 
LIKE=mystring% (to do a real find as you type), default: 0
	searchWholePhrase = 1

	# additional WHERE clause (no AND needed to prepend)
	searchCondition = doktype=255

	# add a CSS class to every list item, default: ''
	cssClass = myclass

	# PHP class alternative receiver class - the file that holds the class 
needs to be included manually before calling the suggest feature 
(default: t3lib_tceforms_suggest_defaultreceiver), should be derived 
from "t3lib_tceforms_suggest_defaultreceiver"
	receiverClass = tx_myext_receiverclass
}

# This TCA value can only be overriden by TCEFORM. TSconfig not by 
TCEMAIN. TSconfig, as this is only valid for the visibility of the 
suggest field, not for the querying
TCEFORM.$table.$field.suggest.default {
	# (int) Minimum number of characters needed when the AJAX call starts 
to run
	minimumCharacters = 2
	# (bool) Hide the suggest field
	hide =  0/1
}

=======

Thanks for testing (also in IE :-)),
All the best,
benni.


More information about the TYPO3-team-core mailing list