blackplan
blackplan

Reputation: 276

how to extend the metadata in TYPO3 10.4.13

I am trying to add a description field under the page properties/metadata which was still present in the TYPO3 8.7.32 version.

I have also already tried in the setup with the following code:

page.meta.description.field = description

#page.meta.description.ifEmpty = 

currently it looks like this enter image description here

and should look like this enter image description here

Upvotes: 1

Views: 496

Answers (1)

Florian Rival
Florian Rival

Reputation: 726

If your goal is to add a SEO description field, this field is already available in the SEO tab.

Nevertheless, if you want to add a new field in metadata, you have to :

Add the new field in : your_ext/ext_tables.sql

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

Override the TCA : create or update the file your_ext/Configuration/TCA/Overrides/pages.php

<?php
defined('TYPO3_MODE') or die();

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

call_user_func(static function () {
    // Define new TCA field
    $additionalFields = [
        'new_field' => [
            'exclude' => false,
            'l10n_mode' => 'prefixLangTitle',
            'label' => 'LLL:EXT:your_ext/Resources/Private/Language/locallang_db.xlf:pages.your_ext',
            'description' => 'LLL:EXT:your_ext/Resources/Private/Language/locallang_db.xlf:pages.your_ext.description',
            'config' => [
                'type' => 'input',
                'size' => 60,
                'max' => 255
            ]
        ]
    ];

    // Add the new TCA columns
    ExtensionManagementUtility::addTCAcolumns('pages', $additionalFields);
    
    // Add the field to the palette
    ExtensionManagementUtility::addFieldsToPalette('pages', 'metatags', 'new_field', 'after:keywords');
});

Then you have to update the DB with BE module Maintenance > Analyze Database Structure.

Flush all cache - because TCA are in cache.

And your new field will now be available.

Upvotes: 2

Related Questions