diff --git a/config/migrations.yaml b/config/migrations.yaml index d0c7eb6..53780dd 100644 --- a/config/migrations.yaml +++ b/config/migrations.yaml @@ -19,3 +19,10 @@ services: - '@contao.framework' tags: - { name: contao.migration, priority: 0 } + + ContaoThemeManager\Core\Migration\Version220\CustomLayoutSectionMigration: + arguments: + - '@database_connection' + - '@contao.framework' + tags: + - { name: contao.migration, priority: 0 } diff --git a/contao/templates/frontend/fe_page.html5 b/contao/templates/frontend/fe_page.html5 index ef53d0f..9e9c8a4 100644 --- a/contao/templates/frontend/fe_page.html5 +++ b/contao/templates/frontend/fe_page.html5 @@ -45,42 +45,46 @@ sections('before'); ?> block('container'); ?> - main || $this->left || $this->right): ?> -
-
- - block('main'); ?> -
-
- main ?> -
- sections('main'); ?> -
- endblock(); ?> - - block('left'); ?> - left): ?> - - - endblock(); ?> - - block('right'); ?> - right): ?> - - - endblock(); ?> - + sections('main'); ?> +
+ endblock(); ?> + + block('left'); ?> + left): ?> + + + endblock(); ?> + + block('right'); ?> + right): ?> + + + endblock(); ?> + +
- - + + section('main-below'); ?> + endblock(); ?> sections('after'); ?> diff --git a/public/framework/scss/ctm_layout/_article-spacing.scss b/public/framework/scss/ctm_layout/_article-spacing.scss index d385f16..dfe55b0 100644 --- a/public/framework/scss/ctm_layout/_article-spacing.scss +++ b/public/framework/scss/ctm_layout/_article-spacing.scss @@ -19,7 +19,7 @@ $spacings-list-bp: ( ); // Add default bottom-padding to #main articles -main { +#main { .mod_article:nth-last-child(n+2) { --mpb:#{$article-main-spacing-bottom}; } .article_inside { padding-bottom: var(--mpb,0); } } diff --git a/src/Migration/Version220/CustomLayoutSectionMigration.php b/src/Migration/Version220/CustomLayoutSectionMigration.php new file mode 100644 index 0000000..012fa83 --- /dev/null +++ b/src/Migration/Version220/CustomLayoutSectionMigration.php @@ -0,0 +1,86 @@ +connection->createSchemaManager(); + + if (!$schemaManager->tablesExist('tl_layout')) + { + return false; + } + + $columns = $schemaManager->listTableColumns('tl_layout'); + + if (!isset($columns['sections'])) + { + return false; + } + + $test = $this->connection->fetchOne("SELECT TRUE FROM tl_layout WHERE sections LIKE '%s:2:\"id\";s:10:\"main-above\";s:8:\"template\";s:13:\"block_section\";s:8:\"position\";s:6:\"before\";%' OR sections LIKE '%s:2:\"id\";s:10:\"main-below\";s:8:\"template\";s:13:\"block_section\";s:8:\"position\";s:5:\"after\";%' LIMIT 1"); + + if (false !== $test) + { + return true; + } + + return false; + } + + /** + * @throws Exception + */ + public function run(): MigrationResult + { + $values = $this->connection->fetchAllKeyValue("SELECT id, sections FROM tl_layout WHERE sections LIKE '%s:2:\"id\";s:10:\"main-above\";s:8:\"template\";s:13:\"block_section\";s:8:\"position\";s:6:\"before\";%' OR sections LIKE '%s:2:\"id\";s:10:\"main-below\";s:8:\"template\";s:13:\"block_section\";s:8:\"position\";s:5:\"after\";%'"); + + foreach ($values as $id => $value) + { + $blnUpdate = false; + + $sections = StringUtil::deserialize($value, true); + + foreach ($sections as &$section) + { + if (!isset($section['id']) || !in_array($section['id'], ['main-above', 'main-below'])) + { + continue; + } + + $section['position'] = 'manual'; + $blnUpdate = true; + } + + if ($blnUpdate) + { + $this->connection->update('tl_layout', ['sections' => serialize($sections)], ['id' => (int) $id]); + } + } + + return $this->createResult(true); + } +}