madeyourday / contao-rocksolid-custom-elements

RockSolid Custom Elements Contao Extension
http://rocksolidthemes.com/de/contao/plugins/custom-content-elements
MIT License
48 stars 12 forks source link

Automatically close wrapper elements #47

Open ausi opened 9 years ago

ausi commented 9 years ago

If possible.

stefanschleich commented 7 years ago

I'd like to see this, too 👍

rustykowski commented 6 years ago

this would be perfect for usability. 👍

mariaj commented 5 years ago

I have written a small local bundle which does the job. The configuration is done in the config file of the custom element by just adding wrapperClose:

... 'wrapper' => array('type' => 'start'), 'wrapperClose' => 'rsce_wrapper_stop', ...

It would be nice, if the feature could be integrated into the next version.

AutoWrapperClose.zip

ngdot commented 5 years ago

I have written a small local bundle which does the job. The configuration is done in the config file of the custom element by just adding wrapperClose:

... 'wrapper' => array('type' => 'start'), 'wrapperClose' => 'rsce_wrapper_stop', ...

It would be nice, if the feature could be integrated into the next version.

AutoWrapperClose.zip

How can I use it in the managed version of contao?

mariaj commented 5 years ago

AutoWrapperClose_v2.zip

I've updated the file. Now it contains the ContaoManagerPlugin.php to register the local bundle and also creates the closing wrapper when copying a single start wrapper. Just extract the zip file into your contao root folder and add the following lines to your composer.json file:

"autoload": {
    "classmap": [
        "app/ContaoManagerPlugin.php"
    ],
    "psr-4": {
        "iq2\\CEAutoWrapperCloseBundle\\": "src/iq2/CEAutoWrapperCloseBundle/"
    }
}
mj1985 commented 4 years ago

Hey @mariaj do I need to add something? I testet the v2 in a managed contao and the wrapper_end won't be added automatically. I already cleared all caches and reloaded the composer class loader.

My start-element:

<?php
return [
    'label' => [ 'Hervorhebung mit Hintergrundbild Anfang', ''],
    'types' => ['content'],
    'contentCategory' => 'Gruppierung',
    'standardFields' => ['cssID'],
    'wrapper' => [
        'type' => 'start'
    ],
    'fields' => [...]
]

My end-element:

 <?php

return [
    'label' => [ 'Hervorhebung mit Hintergrundbild Ende', ''],
    'types' => ['content'],
    'contentCategory' => 'Gruppierung',
    'standardFields' => ['cssID'],
    'wrapper' => [
        'type' => 'close'
    ]
]; 
mariaj commented 4 years ago

Hello mj1985, you have to add the wrapperClose setting to your start-element config file to link the two elements. If the name of the end-element is 'rsce_wrapper_end', it should look like this:

<?php
return [
    'label' => [ 'Hervorhebung mit Hintergrundbild Anfang', ''],
    'types' => ['content'],
    'contentCategory' => 'Gruppierung',
    'standardFields' => ['cssID'],
    'wrapper' => [
        'type' => 'start'
    ],
    'wrapperClose' => 'rsce_wrapper_end',
    'fields' => [...]
]

hope I could help :)

I also have a new version, where I updated the calcuation of the sorting field:
AutoWrapperClose_v2.1.zip

Additional Information: To create a permanent link between the elements, you can look at this: https://community.contao.org/de/showthread.php?74808-Variable-aus-Wrapper-Start-in-Wrapper-Stop-verwenden&p=513862&viewfull=1#post513862 In this example, you can automatically change the data of the end-element dependent on the data of the start-element.

jankout commented 7 months ago

Is there any support for the new logic in Contao 5 for nested content elements planed? That would be great.

ausi commented 7 months ago

Is there any support for the new logic in Contao 5 for nested content elements planed? That would be great.

@jankout This is unrelated to this issue and also a duplicate of #171