[Typo3-dev] CVS question, was t3lib_extMgm::addToTCAtypes ?
"Kasper Skårhøj"
kasper at typo3.com
Tue Sep 30 18:11:18 CEST 2003
In fact, I ended up just adding a paramter to the existing function which now looks like this:
/**
* Makes fields visible on the form, adding them to the end.
*
* Adds a string $str (comma list of field names) to all ["types"][xxx]["showitem"] entries for table $table (unless limited by $specificTypesList)
* This is needed to have new fields shown automatically in the TCEFORMS of a record from $table.
* Typically this function is called after having added new columns (database fields) with the addTCAcolumns function
* FOR USE IN ext_tables.php FILES
*
* @param string Table name
* @param string Field list to add.
* @param string List of specific types to add the field list to. (If empty, all type entries are affected)
* @return void
*/
function addToAllTCAtypes($table,$str,$specificTypesList='') {
global $TCA;
t3lib_div::loadTCA($table);
if (trim($str) && is_array($TCA[$table]) && is_array($TCA[$table]['types'])) {
foreach($TCA[$table]['types'] as $k => $v) {
if (!$specificTypesList || t3lib_div::inList($specificTypesList,$k)) $TCA[$table]['types'][$k]['showitem'].=', '.trim($str);
}
}
}
BTw, this is a good example of how a suggestion improves TYPO3 BUT MUST BE REVIEWED by me - if martin had CVS access to the source and could make this addition himself it would add an unnecessary functions to TYPO3 rather than changing an existing. I'm not saying this to point out martin as a bad coder at all, please notice that. My only point is that this is a very very common example of how good suggestions can be made better and needs my review when they go into the core.
Question: Under the demand that I would require to do the implementation of martins suggestion as above, how could CVS in any way help us? I can only see that as a road block since the code must pass through my eyes anyways!
God bless
- kasper
*********** REPLY SEPARATOR ***********
On 30-09-2003 at 15:26 Martin Kutschker wrote:
>Hi!
>
>I can easily add a field to all pages. How about adding this method?
>
>function addToTCAtypes($table,$types,$str) {
>global $TCA;
>$str = trim($str);
>t3lib_div::loadTCA($table);
>if ($str && is_array($TCA[$table]) &&
>is_array($TCA[$table]['types'])) {
>reset($TCA[$table]['types']);
>$types = split(',',$types);
>while(list(,$v)=each($types)) {
>$TCA[$table]['types'][$v]['showitem'].=', '.$str;
>}
>}
>}
>
>Of course it would be nice if the Extension Kickstarter had an option to
>restrict a new field to specific (page) types.
>
>Masi
>
>_______________________________________________
>Typo3-dev mailing list
>Typo3-dev at lists.netfielders.de
>http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev
God bless
- kasper
- kasper
-------------------- o ---------------------
>>> In God I trust - others pay cash! <<<
Check www.typo3.com
More information about the TYPO3-dev
mailing list