Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add custom page configuration field in TYPO3

Please help,

I created an extension with the Builder Extension. In the extension I included a simple fluid page template.

Then I added a custom page setup field as described in this post.

(1.add DB-Field in ext_tables.sql; 2. add TCA definition in extTables.php)

Unfortunately no field appears. I tried the proposed way (ext_tables.sql):

$tmp_itm_extended_columns_pages = array(
    'customTemplateClass' => array(
        'exclude' => 0,.....

as well as the version from realurl:

$TCA['pages']['columns'] += array(
    'customTemplateClass' => array(
        'label' => 'customTemplateClass'...

Don't know how to get that custom page setup running. Is there a problem combinig it with fluid page templates?

Thanks for help Mathias

like image 479
mcm Avatar asked Jan 09 '23 04:01

mcm


2 Answers

Add custom text field for page configuration within an extension. Here is how I implemented a custom field within my fluid template extension, ready for page level sliding:

1.) Define custom text field: myExt/ext_tables.php

$TCA['pages']['columns'] += array(
    'customTemplateClass' => array(
        'label' => 'Custom Template Class',
        'exclude' => 1,
        'config' => array (
            'type' => 'input',
            'max' => 255,
            'eval' => 'trim,nospace,lower'
        ),
    ),
);

2.) Add the field to the TCA type configuration: myExt/ext_tables.php

t3lib_extMgm::addToAllTCAtypes (
    'pages',
    'customTemplateClass'
);

3.) Write custom field to database: myExt/ext_tables.sql

CREATE TABLE pages (
    customTemplateClass varchar(255) DEFAULT '' NOT NULL
);

4.) Add custom field to rootlinefields for page level sliding: myExt/ext_localconf.php

$rootlinefields = &$GLOBALS["TYPO3_CONF_VARS"]["FE"]["addRootLineFields"];
if($rootlinefields != '')
{
    $rootlinefields .= ' , ';
}
$rootlinefields .= 'customTemplateClass';

5.) Get the custom class of current page or if empty of the parent page: TypoScript:

lib.pageconfig {
    customTemplateClass = TEXT
    customTemplateClass {
        value = default
        override {
           required = 1
           data = levelfield : -1 , customTemplateClass, slide  
        }
    }
}

6.) Output in Fluid-Template file:

{f:cObject(typoscriptObjectPath: 'lib.pageconfig.customTemplateClass')}
like image 93
mcm Avatar answered Jan 15 '23 23:01

mcm


You need to add the field to the TCA type configuration for the table "pages" where it should show up. There is a utility method for adding it to all configured types.

like image 41
Jost Avatar answered Jan 16 '23 01:01

Jost