Search code examples
typo3realurltx-newstypo3-extensions

Migrate TYPO3 realurl.conf fixedPostVars to site extension


I'm building several sites in a multisite TYPO3 v.8.7.1 installation and have created an extension for each site (site package) that includes the typoscript from the tx-news extension.

To rewrite the news extension url's I've added settings to the realurl.conf similar to the advanced example from the doc: https://docs.typo3.org/typo3cms/extensions/news/3.0.0/Main/Administration/Realurl/Index.html

Now, if possible I would like to migrate and sort the multisite realurl.conf settings to isolate each site's configuration in the respective site packages. Could I use the ext_localconf.php for this somehow?

And also I'm curious if it would be possible to set the fixedPostVars pageIds as TypoScript array variables in the setup or constants or the like to make these settings even more available for editing.

Thank you for your time!


Solution

  • Thanks to Kleins answer and a lot of community support I've now managed to set up a solution that is working great.

    First of all, when working with extension realurl rewriting, remember to delete realurl_autoconf.php and clear both typo3 and realurl cache during testing. Also check if realurl variables are applied in the typo3 Configuration Module


    Solution 1, raw config

    Just copy you config to ext_localconf.php


    Solution 2, externalized config

    This is more advanced and worked great for me. (Not sure if Kleins solution might be even better).

    Create namespace class in Classes/RealUrlConf.php and include it in ext_localconf.php. Make sure to follow typo3's required conventions of filepath/namespace configuration.

    Classes/RealUrlConf.php: https://pastebin.com/sg836BhJ

    ext_localconf.php:

    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['extensionConfiguration']['coreRealUrlConf'] = 'Micke\\GenCore\\RealUrlConf->realUrlConfigurer';

    If you want to use the setup just like this you can uncomment the definition and application of the pageIds in the Classes/RealUrlConf.php.


    Solution 3, separate core config from site extensions

    I have created a core package that is drawn as a dependency from the individual site packages in our installation. So in my case I'm settings only the configuration (without yet applying the pageIds) in the core, which is the config mentioned above. In this case without uncommenting anything.

    For each individual sitepackage I then set up a similar configuration that just defines pageIds and applies the core configuration to them. In this was the pageIds are isolated in the individual site packages while most of the configuration resides in the core.

    Classes/RealUrlConf.php: https://pastebin.com/A2xUvrJm

    ext.localconf.php:

    // Include realurl configuration with page IDs $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['extensionConfiguration'][$_EXTKEY . 'realUrlVars'] = 'Micke\\RieSitepack\\RealUrlConf->realUrlConfigurer';

    Good Luck!