CONTRANCE6: FULL WIDTH LAYOUT

created: 23.10.2018 12:21

edited: 11.06.2019 11:27

back

Change: /contrance/Plugin/Contents/Model/Content.php

php
<?php
// ...
$actsAs = [
'BaseData.Layout'     => [
    'layout' => [
        'col12'                 => [
            'title'     => '1/1 Breite',
            'class'     => 'col-xs-12',
            'group'     => 'Allgemein',
            'container' => true,
        ],
        'col6'                  => [
            'title'     => '1/2 Breite',
            'class'     => 'col-xs-12 col-sm-6',
            'group'     => 'Allgemein',
            'container' => true,
        ],
        'col4'                  => [
            'title'     => '1/3 Breite',
            'class'     => 'col-xs-12 col-sm-4',
            'group'     => 'Allgemein',
            'container' => true,
        ],
        'col8'                  => [
            'title'     => '2/3 Breite',
            'class'     => 'col-xs-12 col-sm-8',
            'group'     => 'Allgemein',
            'container' => true,
        ],
        'col3'                  => [
            'title'     => '1/4 Breite',
            'class'     => 'col-xs-12 col-sm-3',
            'group'     => 'Allgemein',
            'container' => true,
        ],
        'full-col12'            => [
            'title'     => '1/1 Breite',
            'class'     => 'full-width', // <= display: block; width: 100%;
            'group'     => 'Volle Breite',
            'container' => false,
        ],
    ],
],
// ...

Edit database.

sql
ALTER TABLE  `contents` CHANGE  `layout`  `layout` ENUM(  'col12',  'col6',  'col8',  'col4',  'col3',  'default',  'full-col12' ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT  'default';

Change: /Plugin/FrontendContents/View/FrontendContents/base.php

php
<?php
ob_start();
echo $this->Html->tag(
    'section',
    $this->fetch('base-content'),
    [
        'class' => [
            'content',
            'type-' . Inflector::underscore($this->view),
            $this->Layout->getClass($row, 'Content.layout')
        ]
    ]
);
if ($this->request->isRequested()) {
    echo ob_get_clean();
}else{
    echo $this->Html->tag(
        'div',
        $this->Html->tag('div', ob_get_clean(), ['class' => 'row']),
        ['class' => 'container col-margin-bottom']
    );
}

Add: /FrontendMenus/View/Elements/requestContent.php

php
<?php
$containerBuffer = '';
foreach ($row[$defaultModel->Content->alias] as $row) {
    $layout = $this->Layout->extract($row, 'layout', 'Content');
    if ($layout['container'] == true) {
        $containerBuffer .= $this->requestAction($row['Route']['route'], ['return']);
    } else {
        if ($containerBuffer) {
            echo $this->Html->tag(
                'div',
                $this->Html->tag('div', $containerBuffer, ['class' => 'row']),
                ['class' => 'container']
            );
            $containerBuffer = '';
        }
        echo $this->requestAction($row['Route']['route'], ['return']);
    }
}
if ($containerBuffer) {
    echo $this->Html->tag(
        'div',
        $this->Html->tag('div', $containerBuffer, ['class' => 'row']),
        ['class' => 'container']
    );
}

Change: /FrontendMenus/View/FrontendMenus/content.php

php
<?php
$this->extend('FrontendMenus.FrontendMenus/base');
$this->append('base-content');
echo $this->element('requestContent');
$this->end('base-content');

Change: /View/Layouts/index.php

php
<div id="content"> <!-- remove .container class -->
    <?php
    echo trim($this->fetch('content'));
    ?>
</div>