Search code examples
typo3typo3-9.xheaderfooter

Typo3: How can i set common data in header and footer like logo?


I want to set a dynamic logo for mobile and desktop versions in header footer. I want to set an email, phone number and address in the footer. how can I set all data in one place? Should I store every page of all data?


Solution

  • Constant is basically for a general setting, you can create in your base template. However, sitepackagebuilder provides minimal setting.

    It's pretty easy! You can create your own constant with simple code below:

    1. Create constant, Add constant in your constant.ts (Generally file path is ext/yourExt/Configuration/TypoScript)

      plugin.tx_yourplugin {
         settings {
             # cat=plugin.tx_yourplugin/file; type=string; label=Website Logo
             siteLogo =
         }
      }
      

    Now, you will find constant in your TYPO3 backend template->constant Editor module, within your extension constants.

    1. Assign a value to setup.ts: Add below code in your setup.ts which is located in the same directory.

      plugin.tx_yourplugin {
          settings {
             siteLogo = {$plugin.tx_yourplugin.settings.siteLogo}
          }
      }
      

    Now, your dynamic value from constant can be accessible to your fluid template or your extbase controller. You will find your constant in the settings user below debug.

    <f:debug>{_all}</f:debug>
    

    Here is some useful link:

    As far as I know, a multiline constant and type file is not yet supported.

    I hope this helps!