2
votes

I am developing a template for TYPO3 version 7. In the backend I've created several backend layouts. In my template (extension) in the setup.ts I check for the IDs of the backend layout to deliver the correct fluidtemplate.

For a more easy use of the template I want to deliver the backend layouts directly with the extension. How to add backend layouts directly from an extension? How to get or set an id for the backend layouts? So I can map this in my setup.ts?

2

2 Answers

3
votes

I normally store the Backend-Layouts in folders to structure the extension.

  • BackendLayouts/ in which all Backend-Layouts are saved
  • BackendLayouts.ts this is where the Layouts are brought together (<INCLUDE_TYPOSCRIPT: source="Path/To/Backendlayout">)

Image: Screenshot of the Structure of the Example

Layout-Setup

The basic Setup for a BE-Layout looks like this:

mod.web_layout.BackendLayouts{
    exampleKey {

        title = Example
        config{
            # Here you paste the generated BE-Layout
        }
    }
}

For example (Default.ts):

mod.web_layout.BackendLayouts{
    default{
        title = Default
        config{
            backend_layout {
                colCount = 2
                rowCount = 2
                rows {
                    1 {
                        columns {
                            1 {
                                name = Slider
                                colspan = 2
                                colPos = 1
                            }
                        }
                    }
                    2 {
                        columns {
                            1 {
                                name = Sidebar
                                colPos = 2
                            }
                            2 {
                                name = Content
                                colPos = 0
                            }
                        }
                    }
                }
            }
        }
    }
}

At last you need to register your Page configuration:

<?php
  if (!defined('TYPO3_MODE')) {
          die ('Access denied.');
  }


  \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile(
          'test_ext',
          'Configuration/TypoScript/Backend/BackendLayouts.ts',
          'My special Backend Layouts'
  );
?>

This only works for Typo3 v7.4.x and higher

Typo3 Backend

  1. Clear cache and reload Backend
  2. Go to the root-Page and edit it
  3. Go to the "Resource" Tab and add your TypoScript Configuration
  4. Save, Reload Page

Now you should be able to see your added Backend Layouts when you edit a page.

Further Actions

If you want to use differnt Templates for every BE-Layout, you can simply do this via the "templateName" porperty in your FLUIDTEMPLATE setup as you can see here: Official TypoScript reference, #templateName

0
votes

You can provide a class that implements the DataProviderInterface for backend layouts. You must then register that class under the key

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['BackendLayoutDataProvider'][$_EXTKEY] = 'Fully\\Qualified\\Namespace\\Of\\The\\Class';

This is possible since TYPO3 6.2.

More references: