TYPO3 CMS Integration & Extension development
Thomas Deuling

Modules

Little helper for creating Backendmodules in TYPO3.

Additionally this extension contains predefined Backend-Modules for:

  • Frontend user (This modules can be disabled in extension manager configuration.)

Another example Backend-Module you'll find in internal_notes Extension in TER. This Extension represents a manager for the internal notes in TYPO3 (sys_notes).

Defining data tables

Defining a data table for the backend can be done easily be using TypoScript.

Attention:

Be sure this TypoScript is defined by a ext_typoscript_setup.txt file, so that this definitions are alwaysavailable!

module.tx_yourextensionkey {
    settings {
        lists {

            downloadFileCollection {
                # Id of the backend module list - just take the parent key
                id = internalNotes
                # table defines the database table name for the records of this list.
                table = sys_note
                # Module identifier
                module = web_InternalNotesInternalNotes
                # Plugin identifier
                plugin = InternalNotes
                # sortingField defines the field, which should be used as default sorting
                sortingField = subject
                # sortingOrder defines the default sorting order for the default sorting field
                sortingOrder = asc
                # The limit defines, how many record should be displayed on each page
                limit = 20
                # Fields/columns of the data table
                fields {
                    # Define the fields/columns of your table
                }
                # Actions for each row of the data table
                actions {
                    # Define the actions for your table rows
                }
            }
            # Define more data tables in the same way
            aSecondTable {
                # ...
            }
        }
    }
}

Define table fields

The field key is written lower-camel-case and represents the getter name of a Model property!

module.tx_yourextensionkey {
    settings {
        lists {
            tableIdentifier {
                fields {
                    title {
                        format = Plain
                        sortable = 1
                    }
                    description {
                        format = PlainEditable
                        sortable = 1
                        crop = 30
                    }
                    creationUser {
                        format = BackendUser/Username
                    }
                    creationDate {
                        format = DateTime
                        sortable = 1
                        dateFormat = d.m.Y H:i
                    }
                }
            }
        }
    }
}

Possible native formats

Parameter/FormatPlainPlainEditableDateTimeEmailBooleanCustom
sortablexxxxx?
dateFormatx
cropxx
  • crop - Crop is an integer value and crops the cell content after the defined amount of characters.

Define table actions

The table actions are defined in the actions node. In this node you are able to define the actions for each table row.

This could look like:

actions {
    # The action key is the identifier.
    # This key is used additionally for the translation key for the column title.
    edit {
        action = Edit
        # Translation keys
        # tx_modules_label.list_topic_action_edit = Edit topic
    }
    hideShow {
        action = HideShow
        # Translation keys
        # tx_modules_label.list_topic_action_hide = Hide topic
        # tx_modules_label.list_topic_action_show = Show topic
    }
    disableEnable {
        action = DisableEnable
        # Translation keys
        # tx_modules_label.list_frontend_user_action_enable = Enable frontend user
        # tx_modules_label.list_frontend_user_action_disable = Disable frontend user
    }
    delete {
        action = Delete
        # Data field of the record, where a label is store.
        # This label is used for the security question in the modal.
        subjectField = title
        # Translation keys
        # tx_modules_label.list_topic_action_delete_title = Delete this topic?
        # tx_modules_label.list_topic_action_delete_content = Are you sure you want to delete the topic '%1$s'?
        # tx_modules_label.list_topic_action_delete_cancel = Cancel
    }
}

Translations

Defining translations for the data tables works like this:

module.tx_yourextensionkey {
    _LOCAL_LANG {
        default {
            #
            tx_downloadmanager_label.backend_filter = Filter
            tx_downloadmanager_label.backend_filter_submit = refresh

            # Message, if there are no records in the table
            tx_modules_label.list_download_file_collection_no_entries = No download file collections found

            # Table header title
            tx_modules_label.list_download_file_collection_header = Download file collection

            # Table header columns
            # Each identifier is build like:
            # tx_modules_label.list_ + list id underscored + _col_ + field key
            tx_modules_label.list_download_file_collection_col_title = Title
            tx_modules_label.list_download_file_collection_col_actions = Actions

            tx_modules_label.list_download_file_collection_action_edit = Edit download file collection
            tx_modules_label.list_download_file_collection_action_hide = Hide download file collection
            tx_modules_label.list_download_file_collection_action_show = Show download file collection
        }
        de {
            # German translation
            tx_modules_label.list_download_file_collection_no_entries = Es konnten keine Download-Datei-Dateisammlung gefunden werden
            tx_modules_label.list_download_file_collection_header = Download-Dateisammlung
            tx_modules_label.list_download_file_collection_col_title = Titel
            tx_modules_label.list_download_file_collection_col_actions = Aktionen
            tx_modules_label.list_download_file_collection_action_edit = Download-Dateisammlung bearbeiten
        }
    }
}

Using creation user, date or modifictaion date

When you want to use the creation user, date or modification date of a default TYPO3 record, you need to map the Extbasefields:

config.tx_extbase.persistence.classes {

    CodingMs\Newsletters\Domain\Model\Topic.mapping {
        tableName = tx_newsletters_domain_model_topic
        recordType =
        columns {
            crdate.mapOnProperty = creationDate
            tstamp.mapOnProperty = modificationDate
            cruser_id.mapOnProperty = creationUser
        }
    }

}

Additionally you need the respecting getter and setter in the related Extbase-Model.

FAQ

Why does the HideShow action not work as expected?

Maybe you've forgotten to add the hidden properties to your Model. Add the following:

/**
 * @var boolean
 */
protected $hidden;

/**
 * @return bool
 */
public function isHidden()
{
    return $this->hidden;
}

/**
 * @param bool $hidden
 */
public function setHidden($hidden)
{
    $this->hidden = $hidden;
}

Why does the delete modal not appears?

Maybe you've forgotten to add the required RequireJs-Module:

$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');