Search code examples
typo3typoscripttypo3-extensions

TYPO3 changing an extension with own extension


I'm trying to create a extension to modify fields in a different extension. My extension needs to add and disable fields in fe_users over the TSConfig Page.

Ive looked over google how to do this with a own extension. But I didn't find anything usefull that I could work with.

(Edited)

The admin shouldn't be able to see these fields:

  • Company
  • Name
  • Middle name
  • Address
  • Zipcode
  • Land
  • Phone
  • Fax
  • www
  • Image
  • TSConfig
  • Bind a Domain
  • Redirect after login
  • Start
  • Stop
  • Record Type

These fields should be added

  • Customer (INT, not able to edit on display) Manditory
  • swissaxis_id (INT, Unique number) if possible only displayable and not editing possibility
  • shop_rights (Textarea, No defined Value. The Rights will be saved there serialised.)

fe_groups

These fields shouldn't be displayed to any Admin

  • Bind a domain
  • TSConfig
  • Redirect after login
  • Record Type

I'm thankfull for any Feedback possible.


Solution

  • Here's a link on how you add new fields to fe_users: https://docs.typo3.org/typo3cms/TCAReference/ExtendingTca/Index.html https://docs.typo3.org/typo3cms/TCAReference/ExtendingTca/Examples/Index.html

    I'll give you an example from an old, makeshift extension zusatzfelder of mine that modifies the "pages" table. It's really old, please verify if everything is current. You can also look at any other, "real" extension...

    ext_emconf.php (maybe created by extension_builder)

    <?php
    
    ########################################################################
    # Extension Manager/Repository config file for ext "zusatzfelder".
    #
    # Auto generated 29-08-2011 15:33
    #
    # Manual updates:
    # Only the data in the array - everything else is removed by next
    # writing. "version" and "dependencies" must not be touched!
    ########################################################################
    
    $EM_CONF[$_EXTKEY] = array(
        'title' => 'Zusatzfelder',
        'description' => '',
        'category' => '',
        'author' => '',
        'author_email' => '',
        'shy' => '',
        'dependencies' => '',
        'conflicts' => '',
        'priority' => '',
        'module' => '',
        'state' => '',
        'internal' => '',
        'uploadfolder' => 0,
        'createDirs' => '',
        'modify_tables' => '',
        'clearCacheOnLoad' => 0,
        'lockType' => '',
        'author_company' => '',
        'version' => '0.0.0',
        'constraints' => array(
            'depends' => array(
            ),
            'conflicts' => array(
            ),
            'suggests' => array(
            ),
        ),
        '_md5_values_when_last_written' => 'a:8:{s:9:"ChangeLog";s:4:"5b94";s:10:"README.txt";s:4:"ee2d";s:12:"ext_icon.gif";s:4:"1bdc";s:14:"ext_tables.php";s:4:"474a";s:14:"ext_tables.sql";s:4:"ead9";s:16:"locallang_db.xml";s:4:"7a92";s:19:"doc/wizard_form.dat";s:4:"0cba";s:20:"doc/wizard_form.html";s:4:"29e8";}',
    );
    
    ?>
    

    ext_tables.sql

    CREATE TABLE pages (
            tx_zusatzfelder_contentnav_title_addition tinytext,
            tx_zusatzfelder_contentnav_title tinytext,
            tx_zusatzfelder_contentnav_disable int(11) DEFAULT '0' NOT NULL,
    );
    

    ext_tables.php

    <?php
    if (!defined('TYPO3_MODE')) {
        die ('Access denied.');
    }
    $tempColumns = array (
        'tx_zusatzfelder_contentnav_title' => array (       
            'exclude' => 0,     
            'label' => 'LLL:EXT:zusatzfelder/locallang_db.xml:pages.tx_zusatzfelder_contentnav_title',      
            'config' => array (
                'type' => 'input',  
                'size' => '30',
            )
        ),
        'tx_zusatzfelder_contentnav_title_addition' => array (      
            'exclude' => 0,     
            'label' => 'LLL:EXT:zusatzfelder/locallang_db.xml:pages.tx_zusatzfelder_contentnav_title_addition',     
            'config' => array (
                'type' => 'input',  
                'size' => '30',
            )
        ),
        'tx_zusatzfelder_contentnav_disable' => array (     
            'exclude' => 0,     
            'label' => 'LLL:EXT:zusatzfelder/locallang_db.xml:pages.tx_zusatzfelder_contentnav_disable',        
            'config' => array (
                'type' => 'check',  
                'default' => '0',
            )
        ),
    );
    
    
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages',$tempColumns,1);
    // http://typo3-blog.net/tutorials/news/addtoalltcatypes.html
    // PS: the "after:"... is for placement in the BE, stopped working last week...
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages','tx_zusatzfelder_contentnav_title;;;;1-1-1','','after:subtitle');
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages','tx_zusatzfelder_contentnav_title_addition;;;;1-1-1','','after:subtitle');
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages','tx_zusatzfelder_contentnav_disable;;;;1-1-1','','after:subtitle');
    ?>
    

    locallang_db.xml

    <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
    <T3locallang>
        <meta type="array">
            <type>database</type>
            <description>Language labels for database tables/fields belonging to extension 'zusatzfelder'</description>
        </meta>
        <data type="array">
            <languageKey index="default" type="array">
                <label index="pages.tx_zusatzfelder_contentnav_title_addition">Untermenu: Vorlauf Titel (zB. "Mehr zur")</label>
                <label index="pages.tx_zusatzfelder_contentnav_title">Untermenu: Titellink anderer Text (Standard: Seitentitel; Leerschlag: kein Titel)</label>
                <label index="pages.tx_zusatzfelder_contentnav_disable">Untermenu ausblenden</label>
            </languageKey>
        </data>
    </T3locallang>
    

    That's all you need to add new fields – you don't even need the locallang if you just prefer to do 'label' => 'My untranslated Label', in ext_tables.php.