Search code examples
typo3typoscripttsconfig

How to display only records in a select field, which are in a certain storagePid in TYPO3?


Is it possible to configure this in .tsconfig or .typoscript files?


Solution

  • In the TCA you can configure foreign_table_where for a select.
    Here you can add a selection on special page IDs.
    These IDs could be configured by a marker, e.g. ###PAGE_TSCONFIG_ID### (A value you can set from Page TSconfig dynamically.)


    EDIT:

    let's see the example from the manual:

    'select_single_3' => [
        'label' => 'select_single_3 static values, dividers, foreign_table_where',
        'config' => [
            'type' => 'select',
            'renderType' => 'selectSingle',
            'items' => [
                ['Static values', '--div--'],
                ['static -2', -2],
                ['static -1', -1],
                ['DB values', '--div--'],
            ],
            'foreign_table' => 'tx_styleguide_staticdata',
            'foreign_table_where' => 'AND {#tx_styleguide_staticdata}.{#value_1} LIKE \'%foo%\' ORDER BY uid',
            'foreign_table_prefix' => 'A prefix: ',
        ],
    ],
    

    modifying the foreign_table_where to your needs:

    'foreign_table_where' => 'AND {#tx_styleguide_staticdata}.{#pid} = ###PAGE_TSCONFIG_ID###',
    

    and the definition for this marker would be:

    TCEFORM.tx_myext_domin_model_record.select_single_3.PAGE_TSCONFIG_ID = 22
    

    in general:

    TCEFORM.<table>.<field>.PAGE_TSCONFIG_ID = 22