问题
What would be the recommended method to add custom page property fields in TYPO3 6.2?
In 4.5 I used TemplaVoila which had its own page module and made it easy to add data records on a page level.
回答1:
There are several approaches:
- The "vanilla" approach:
Create an extension (and with it the file ext_emconf.php
) and then create a file ext_tables.sql
in the extension root. In it you can put SQL-definitions for the new fields, by defining a CREATE TABLE
statement for the pages table:
CREATE TABLE pages(
myNewField int(11) DEFAULT '',
);
This SQL-definition will be merged with existing definitions for the table page
.
Then you need to configure the new field in the Table Configuration Array (TCA). You can usually find good examples in existing extensions, for example in realurl
. There are two places where you can put these definitions, either in the file ext_tables.php
(uncached), or into a php file in the folder Configuration/Tca/Overrides
(cached).
This approach sounds like more work than it actually is.
Just use TemplaVoila. It is available for TYPO3 6.2, but its future is uncertain, AFAIK.
Use the fluidtypo3-Ecosystem of extensions, and especially the extension
fluidpages
. It does what you want, in a similar way to TemplaVoila, but with modern (= fluid-based) technologies.
回答2:
if you need your own custom content elements, i recommend the extension "DCE" (Dynamic Content Elements).
DCE is really easy to customise and you can create Content elements in some minutes.
Also you can do it like Jost said. Do it with an own extension and put the TCA definition in your extTables.php
As example:
/www/htdocs/website/typo3conf/ext/custom_extension/ext_tables.php
$tmp_itm_extended_columns_pages = array(
'link_class' => array(
'exclude' => 0,
'label' => 'LLL:EXT:itm_extended/Resources/Private/Language/locallang_db.xlf:label.linkClass',
'config' => array(
'type' => 'select',
'items' => array(
array('Nichts', ''),
array('Zahnrad', 'icon-afford', 'EXT:custom_extension/Resources/Public/img/icons/icon_preferences_small.png'),
array('Fabrik', 'icon-factory', 'EXT:custom_extension/Resources/Public/img/icons/icon_factory_small.png'),
array('Computer', 'icon-software', 'EXT:custom_extension/Resources/Public/img/icons/icon_software_small.png'),
array('Person', 'icon-jobs', 'EXT:custom_extension/Resources/Public/img/icons/icon_person_small.png'),
array('Welt', 'icon-world', 'EXT:custom_extension/Resources/Public/img/icons/icon_world_small.png'),
array('Rohre', 'icon-pipe', 'EXT:custom_extension/Resources/Public/img/icons/icon_pipe_small.png'),
),
),
),
);
Then you have to add your new field to the ext_tables.sql
#
# Table structure for table 'pages'
#
CREATE TABLE pages (
link_class text
);
来源:https://stackoverflow.com/questions/26144587/additional-page-property-fields-in-typo3-cms-6-2