You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TYPO3扩展插件TypoScript不生效及默认StoragePid配置问题求助

Let's break down your two TYPO3 configuration issues step by step—they're rooted in how TYPO3 handles extension TypoScript and backend record defaults:

1. Loading TypoScript only on pages with your plugin

The reason your TypoScript in typo3conf/ext/my_company_plugin/Configuration/TypoScript/setup.txt isn't kicking in is twofold: first, TYPO3 doesn't auto-include extension static TypoScript unless you register it, and second, even if you do register it, it loads across your whole site by default. To restrict it only to pages where your plugin is present, here are two reliable fixes:

Option 1: Use a TypoScript condition (most precise)

Wrap your plugin-specific code in a condition that checks if the current page contains your plugin. Replace tx_mycompanyplugin_pi1 with your actual plugin key (you can find this in your extension's ext_localconf.php where you call configurePlugin()):

[page|containsPlugin = tx_mycompanyplugin_pi1]
    page.includeCSS {
        myplugin = EXT:my_company_plugin/Resources/Public/Css/plugin-styles.css
    }
    page.includeJS {
        myplugin = EXT:my_company_plugin/Resources/Public/JS/plugin-scripts.js
    }
    lib.my_block = COA
    # ... add all your plugin-specific TypoScript here
[global]

You can place this either in your main site template's setup section, or keep it in your extension's setup.txt (just make sure your extension's static TS is included in the site template first—see Option 2 for how to register it).

Option 2: Register extension static TypoScript (site-wide with plugin-specific logic)

First, register your extension's static TypoScript so TYPO3 recognizes it. Add this to your extension's ext_localconf.php:

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
    'my_company_plugin',
    'Configuration/TypoScript',
    'My Company Plugin: Frontend Styles & Logic'
);

Then, go to your site template (Template > Edit the whole template record > Includes tab) and check the box for your extension's static TS entry. If you still want to restrict the code to plugin pages, combine this with the condition method above.


2. Setting a default storagePid for your backend module's entities

Your current attempt with module.tx_company_events.persistence.storagePid in setup.txt isn't working because backend modules don't pick up that specific TypoScript path for default record storage. Instead, you need to target either the TCA (Table Configuration Array) for your entity or use TSconfig, which is designed for backend behavior:

Option 1: Set default_pid in your entity's TCA (most reliable)

This is the direct way to enforce a default storage folder for new records. Open your entity's TCA file (e.g., typo3conf/ext/my_company_plugin/Configuration/TCA/tx_companyevents_domain_model_event.php) and add the default_pid option to the ctrl array:

return [
    'ctrl' => [
        'title' => 'Event',
        'label' => 'title',
        'default_pid' => 184, // Forces new records to save to folder UID 184 by default
        'tstamp' => 'tstamp',
        'crdate' => 'crdate',
        // ... keep your existing ctrl settings
    ],
    // ... rest of your TCA configuration
];

After making this change, clear TYPO3's system cache. New records created via your backend module will now default to UID 184.

Option 2: Use Page/User TSconfig (for flexible overrides)

If you need different defaults for specific user groups or page trees, add this to your Page TSconfig (or User TSconfig in the backend user settings):

tx_company_events.persistence.storagePid = 184

Or target the backend module directly:

module.tx_company_events.persistence.storagePid = 184

Important note: The TCA default_pid setting takes priority over TSconfig, so if you use both, stick with the TCA method for consistency. Also, double-check that the storage folder with UID 184 exists and that your backend user has permission to create records in it—TYPO3 will fall back to the current page's PID if permissions are missing.


内容的提问来源于stack exchange,提问作者Paolito75

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:08:19