Verbesserungsvorschlag: Custom Elements - multiSRC mit Sortierfunktion

Marco Müller's Avatar

Marco Müller

02 Jun, 2015 01:23 PM

Produkt: Custom Elements Contao
Contao-Version: 3.4.5

Hallo,

erstmal vielen Dank für die tolle Erweiterung.

Ich habe heute versucht ein multiSRC anzulegen um deren Sortierfunktion nutzen zu können.
Das Feld würde mir richtig angezeigt und ich konnte die Bilder auch verschieben. Leider würde die Änderung an der Sortierung nicht gespeichert. Ist dieses Problem irgendwie zu lösen oder habe ich einen Fehler gemacht?
Hier der Code, den ich benutzt habe:

<?php
// rsce_my_element_config.php
return array(
    'label' => array('Test', 'Meine Beschreibung...'),
    'types' => array('content', 'module'),
    'contentCategory' => 'Test Elements',
    'moduleCategory' => 'miscellaneous',
    'standardFields' => array('headline', 'cssID', ),
    'fields' => array(
        'boxes' => array(
            'label' => array('Textboxen', ''),
            'elementLabel' => '%s. Box',
            'inputType' => 'list',
            'minItems' => 1,
            'maxItems' => 5,
            'fields' => array(
                'text' => array(
                    'label' => array('Text', ''),
                    'eval' => array('rte' => 'tinyMCE'),
                    'inputType' => 'textarea',
                ),
                
                'multiSRC' => array(
                    'label' => array('Bild', ''),
                    'inputType' => 'fileTree',
                    'eval' => array(
                        'multiple'=>true, 
                        'fieldType'=>'checkbox', 
                        'orderField'=>'orderSRC', 
                        'files'=>true, 
                        'mandatory'=>true
                    )
                ),
            ),
        ),
    ),
);

Grüße Marco Müller

  1. Support Staff 1 Posted by RockSolid Theme... on 02 Jun, 2015 02:30 PM

    RockSolid Themes's Avatar

    Vielen Dank für Ihre Frage.

    Das Widget fileTree erwartet als orderField eine Tabellen-Spalte, deshalb ist die Sortierfunktion derzeit leider nicht mit den Custom Elements kompatibel.

  2. 2 Posted by Marco Müller on 02 Jun, 2015 02:37 PM

    Marco Müller's Avatar

    Vielen Dank für die schnelle Antwort.
    Wie hoch wäre der Aufwand dieses Feature zu implementieren?

  3. Support Staff 3 Posted by RockSolid Theme... on 03 Jun, 2015 08:13 AM

    RockSolid Themes's Avatar

    Das Widget fileTree kommt von Contao selbst und müsste dort verändert werden.

  4. 4 Posted by Daniel Bitsch on 15 Dec, 2021 04:17 PM

    Daniel Bitsch's Avatar

    Produkt: Custom Elements Contao
    Contao-Version: 4.9.17

    Hallo,
    besteht das Problem immer noch, dass die Sortierfunktion vom Widget fileTree mit den Custom Elements nicht funktioniert?

    Grüße Daniel Bitsch

  5. 5 Posted by Marco on 15 Dec, 2021 04:25 PM

    Marco's Avatar

    Bei mir funktioniert das hier.

    Config Datei

    'multiSRC2' => array
            (
                'label' => array('Bilder für Galerie auswählen (klein)', ''),
    'inputType' => 'fileTree',
    'eval' => array('multiple'=>true, 'fieldType'=>'checkbox', 'orderField'=>'orderSRC', 'files'=>true, 'mandatory'=>true, 'tl_class'=>'clr'),
    'sql' => "blob NULL",
    'load_callback' => array
    (
    array('tl_content', 'setMultiSrcFlags')
    )
            ),

    Template Datei

    <?php
    $tmp = array_map('StringUtil::binToUuid', deserialize($this->orderSRC, true));
    $images = $this->multiSRC2;

    if (!empty($tmp)) {
        $arrOrder = array_map(function() {}, array_flip($tmp));
        foreach ($images as $k=>$v) {
            if (array_key_exists($v, $arrOrder)) {
                $arrOrder[$v] = $v;
                unset($images[$k]);
            }
        }
        if (!empty($images)) {
            $arrOrder = array_merge($arrOrder, array_values($images));
        }
        $images = array_values(array_filter($arrOrder));
        unset($arrOrder);
    }
    ?>

    <?php if ($this->multiSRC2) { ?>
                                <div class="slideshow_small">
                                    <?php foreach ($images as $index => $galerie): ?>
                                    <div>
                                        <?php if ($image = $this->arrData['getImageObject']($galerie)){ ?>
                                            <a href="<?php echo $image->src; ?>" data-fancybox="Galerie2">
                                                <img src="<?php echo $image->src ?>" alt="<?php echo $image->alt ?>">
                                            </a>
                                        <?php } ?>
                                    </div>
                                <?php endforeach ?>
                                </div>
                            <?php } ?>

  6. Support Staff 6 Posted by RockSolid Theme... on 16 Dec, 2021 10:38 AM

    RockSolid Themes's Avatar

    besteht das Problem immer noch, dass die Sortierfunktion vom Widget fileTree mit den Custom Elements nicht funktioniert?

    Nein, seit der Version 4.11 von Contao kann die Sortierung über 'isSortable' => true, im eval-Array aktiviert werden.

    Weitere Informationen zu dieser Einstellung finden Sie in der Dokumentation von Contao: https://docs.contao.org/dev/reference/dca/fields/#evaluation

  7. 7 Posted by Daniel Bitsch on 16 Dec, 2021 04:20 PM

    Daniel Bitsch's Avatar

    Vielen lieben Dank Marco, dass Du Deine Lösung mit mir geteilt hast. Hat super funktioniert.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac