
5. Add the new TCA value to ext_tables.php
Go ahead and switch back to your text editor and add this value to ext_tables.php. Just make sure you add it after the line that loads the TCA array. I'm going to go ahead and change the value from 3 to 6 so that more values show up in this field:
Adding this line to ext_tables.php in our extension will allow our extension to override the default value for the size property of the usergroup field in frontend user records. You might want to take some time at this point to look at what other options are present in the TCA. Notice that all of the labels for the fields are stored there as well. You could just as easily use your new extension to modify these labels so that they're more instructive, more descriptive, or more suited to the needs of your particular client. You can also add values to the config array of a field besides those that are already present. For a good reference of what's available in the TCA, check out the Inside TYPO3 document (link included at the end of this article).
6. Last step. I promise!
There's just one more thing that we need to do for our changes to go into effect, and I suspect you've already guess what it is -- we need to load our extension! Go to the extension manager and bring up the list of available extensions to install. Find your extension and install it.
If everything has gone according to plan, you should now see that the usergroups field in frontend user records contains six slots instead of three. Here's what it looked like before our modifications:
And here's what it looks like after our modifications have gone into effect:
Looks like it worked! To make more modifications to the TCA, go ahead and add more lines to the ext_tables.php file that you created; just make sure you add them below the LoadTCA method call.
A word of warning
When TYPO3 is executed, it caches all of the values in each ext_tables.php file in a temporary file, which is stored in the typo3conf folder. This file generally will have a name like temp_CACHED_ps9ed5_ext_tables.php. When you clear the backend cache, this file is deleted as is the localconf.php file. Generally, you can also manually delete these files if something goes wrong. The danger when messing around with an ext_tables.php file is that you will make a mistake and accidentally leave out a semicolon or mess up the PHP syntax somehow. If you do this, TYPO3 will try to parse your ext_tables.php file and it will fail. The bad code will also be cached in the cached version of ext_tables.php, which may prevent the backend from loading. If this happens, you will want to fix / move / delete the offending ext_tables.php file and remove the cached version of ext_tables.php in typo3conf. Doing so should allow TYPO3 to recreated the global ext_tables.php. Assuming you've removed whatever was causing the error, the backend should load successfully.
As with any articles posted here, Cast Iron Coding cannot be held responsible for any damage you do to your site. This is fairly advanced stuff, so you should make sure you know what you are doing.
Have questions, comments, or corrections? Send me an email at zach(at)castironcoding.com.