This extension, allows you to easily define tables and the fields they contain. Instead of typing together an ext_tables.sql where you define the database definition of an table, and ext_tables.php and all other files TYPO3 requires, you simply set up some records defining your table structure and the just let kb_kickstarter generate all required files.
Here is a little introduction picked with screenshots which will show you how to set up a table with kb_kickstart.
Setting up the kickstarter extension¶
Simply install the kickstarter extension from TER, forge SVN, or a T3X. When installing the extension you only have to set a few options defining the prefixes which should get used for tables and fields, and a "Configuration extension":
The "Table prefix" and "Field prefix" values simply define a prefix, which will get used when new tables get defined. So lets say you are going to create a table called "schools", then the table created in the database will have the name "tx_kbks_schools" if you leave the default prefix "tx_kbks_". The same applies to fields created in this table. So if you create a field "address" for it will be called "tx_kbks_address".
The "Configuration extension" is an empty extension only containing a empty file "kb_kickstarter_config.txt" which marks it as configuration extension. You can either use the nothing extension from TER, create an empty extension on your own, or use the kb_config extension from TER (currently not available), Forge SVN or get the T3X from my server
When installing the "Smarty" extension you'll have to check the checkbox "ATTENTION, Upgrade the Smarty path" (Thanks to Lukas Taferner for pointing this out).
Creating tables and fields¶
After having installed the extension, it is the best think, to create a new empty sysfolder somewhere in your Page-Tree. A good place is somewhere next to your TypoScript-Template SysFolder, your DS/TO Storage or any other of those kind of pages. It is not necessary, to have your own sysfolder for kb_kickstarter records, but it makes life easier. If you have your new sysfolder, just start to create new records of the type "Kickstarter: Table" or "Kickstarter: Field". Of course the created records to not have to do something with lunch-tables or football fields. Those icons have just be choosen to bring some fun into your life ;)
The first thing to do is probably to create some fields your tables are going to have. It is not a good idea to start creating a table, as you wont be able to assign any fields to this table, and fields are a mandatory thing for tables. So first create a "Kickstarter: Field" record:
It is completly ok, that you get the Flexform error directly after creating a new field record, as the flexform is only available after selecting the type of field. Choose the type of field in the "Field type" drop-down, when asked to reload the page confirm it. On the subsequent page, you will have all field, required for configuring a field. You can create fields like:
- Simple text (string) fields
- Textfields without RTE
- Fields containig decimal or double(2) values.
- File fields
- Database relations
- Container (IRRE) fields
For Experts: If you need other field-types it is not hard to add new ones as every field type is just a subdirectory in the extensions "fieldTypes" directory. Have a look at them. You need to define a flexform template for setting up the field, and a bunch of smarty templates for generating the TCA and ext_tables code for the field. But this whole process is not described here.
When you have choosen a field type, you'll have to set all required and/or wanted values to configure this field. When done simply save the record and create all other fields required for your table. If you have finished creating all required fields, and you are ready to define the table for which you have created the fields before, simply add a "Kickstarter: Table" record in the sysfolder:
If you create a table record, you have to fill out some information about the table you are going to create. This is a short description, what each field means:
- Table name: This will be the name of the table, as shown when creating a new, record, etc. It will be the "ctrl / title" of TCA.
- Table alias: This will be the name of the table in the database, prefixed with the table prefix you set when installing the extension. So if you choose "schools" here, a table called "tx_kbks_schools" will get created in the database.
- Table icon: This icon will get shown before each record as clickmenu icon, when creating a new record, and in any other places where a table-icon is appropriate
- Fields: This selectbox allows you to select a number of fields which you would like to have in this table. So if you created fields "address", "zip", "city", etc, you simply have to select them in this box, and the generated table will have this fields available
- Label fields: This fields get used as label for the generated table. It will be the "ctrl / label" of TCA.
- Sorting fields: The fields selected here will define how the records of the new table will be sorted. If you do not select any fields, you will be able to manually sort the records of the new table using up/down arrows (like for tt_content elements)
- Allow table on standard pages: When this checkbox is set records of the new table can get created on any page, not just in sysfolders
- FE-User owner field: Using this drop-down you can select a field which holds the uid of the user owning a record. This is a rather complicated feature, which can make life easier, when FE-Users "own" a record. For example if FE-Users submit offers for private school lessons in some kind of school-websites, this drop-down should contain the name of the field of the user who submitted such a "private lesson" record
- Enable Visibility: When this flag is set, the created table will have a "Hide" checkbox/flag. This allows to hide/unhide the records of the newly created table.
- Enable Time-Control: When this flag is set, the records of the new table will have Starttime/Endtime fields
- Enable Access-Control: When this flag is set, the records of the new table will have an "Access" drop down, allowing to set the Usergroup having access to those records.
Most of the above fields just enable or set an option in the TCAs "ctrl" section. For reference to most of this options you should check out the TYPO3 Core API documentation on the CTRL section.
Now if you are done setting up your table and fields, the sysfolder containing your work will probably look like this one:
Ok. Probably you just create one table in the beginning, but the tables/fields shown here are from a real-live project. So if you are done setting up your table/field records, and would like to create the first record of your new table, you'll first have to let the defined table get generated by the kb_kickstarter extension.
The "Kick Admin" module¶
In the main menu of TYPO3 you should have a menu item labeled "Kick Admin" in the "Tools" section. If you click on this module, you will be taken to the kickadmin module, which allows you to (re)generated all files required by TYPO3 to handle the table you just defined. It will look somehow like in the following picture:
What you see here are a handful of tables, which have been defined using the kickstarter extension. The fields which red show up that some part of the configuration set in the database "Kickstarter: Table" records for this table does not match the current configuration as it is understood by TYPO3. So if you created a "Kickstarter: Table" record, and assigned it some fields, this table will only exist as definition, TYPO3 will not be able to create any records or use this table in any other way - in fact this table will most likely not even exist in the database. Such table will show up completly in red in the "Kick Admin" module. You can update everything which should get updated, by pressing the button "Update all tables" in the bottom right.
After pressing this button, the "tca.php", "ext_tables.php", "ext_tables.sql" and "locallang.xml" files will get created after your specifications. Those files will get stored in the configuration extension which you specified in the very first step of this tutorial - when installing the extension. In most cases, if you changed something to fields or other database relevant values/records the Button "Database update" button at the bottom of the Kick Admin will show up in red after updating the table definitions. By pressing the "Update databse" button, you bring the database to an actual state which matches the configuration you set up for all tables/fields.
Finally the Kick Admin should look somehow like in the following picture:
Now you just have to clear the TYPO3 Configuration cache, using the flash icon on the top panel menu. After clearing the TYPO3 configuration cache, you can visit some sysfolder, and try out if you can create the tables you just defined:
Of course it makes no sense here, to show the editform of one of the created tables, as it will depend on whatever type of fields you assigned to your tables.
Now just try out every feature of this extension. If something is not obvious or you have other questions, feel free to ask me via mail: firstname.lastname@example.org
And look out for the "kb_display" extension which I will soon release at forge. It allows you to display lists, or single-views of records created with kb_kickstarter, or even simple normal TYPO3 records like "tt_address" or records from 3rd party extensions. So you'll never need to code a "Just show some addresses" extension again ;)
PS: Below pictures are just the screenshots used on this wiki page.