vaersaagod / matrixmate

Welding Matrix into shape, mate!
MIT License
44 stars 9 forks source link

Tabs not working for specific matrixblocks inside matrixblocks #30

Closed Joorren closed 3 years ago

Joorren commented 3 years ago

Using the configuration below, tabs do show for the 'contentBlocks' (main Matrix) and 'hero' (child Matrix) matrix blocks. But I cannot seem to get it working for the 'columns' (child Matrix) and 'callToAction' (child Matrix) matrix blocks.

Is there something I'm missing or misunderstood?

This is a small preview of what my Matrix field looks like:

contentBlocks (Matrix)

hero (Matrix Block Type)

hero (Super Table)

hero (Matrix)

primaryHero (Matrix Block Type)

heading (Plain Text) body (Redactor) settings (Super Table)

secondaryHero (Matrix Block Type)

body (Redactor) settings (Super Table)

callToActions (Matrix Block Type)

callToActions (Super Table)

callToActions (Matrix)

button (Matrix Block Type)

callToAction (Super Table) settings (Super Table)

textButton (Matrix Block Type)

body (Redactor) callToActions (Super Table) settings (Super Table)


<?php

$content_blocks = [
    'logoLint', 'testimonials', 'subheading', 'heading', 'body', 'image', 'heroImage', 'form', 'contactList',
    'faq', 'columns', 'video', 'icon', 'downloadAsset', 'contentBlocks', 'default', 'iconHeader',
    'imageHeader', 'card', 'quote', 'authorName', 'company', 'hero', 'members',
];
$cta_blocks = ['callToActions', 'callToAction'];
$setting_blocks = ['settings'];

$matrixes = [
    'contentBlocks' => [
        'text', 'textImage', 'image', 'video', 'faq', 'heading', 'logoLint', 'quote', 'testimonials',
        'callToActions', 'columns', 'hero', 'team',
    ],
    'hero' => [
        'primaryHero', 'secondaryHero', 'formHero',
    ],
    'columns' => [
        'default', 'iconHeader', 'imageHeader', 'card',
    ],
    'callToActions' => [
        'button', 'centeredTextButton', 'textForm', 'downloadForm', 'form',
    ],
];

$types = [];

foreach ($matrixes as $key => $field) {
    $types[$key] = [];
    foreach ($field as $type) {
        $types[$key][$type] = [
            'tabs' => [
                [
                    'label' => 'Content',
                    'fields' => $content_blocks,
                ],
                [
                    'label' => 'Call To Action(s)',
                    'fields' => $cta_blocks,
                ],
                [
                    'label' => 'Settings',
                    'fields' => $setting_blocks,
                ],
            ],
        ];
    }
}

return [
    'fields' => [
        'contentBlocks' => [
            'groups' => [
                [
                    'label' => 'Text',
                    'types' => ['text', 'textImage', 'heading'],
                ],
                [
                    'label' => 'Image + Video',
                    'types' => ['textImage', 'image', 'video'],
                ],
                [
                    'label' => 'Blocks',
                    'types' => ['faq', 'heading', 'logoLint', 'quote', 'testimonials', 'team'],
                ],
            ],
            'types' => $types['contentBlocks']
        ],
        'hero' => [
            'types' => $types['hero']
        ],
        'columns' => [
            'types' => $types['columns']
        ],
        'callToActions' => [
            'types' => $types['callToActions']
        ],
    ],
];
mmikkel commented 3 years ago

This is expected behavior; MatrixMate does not support Matrix fields nested in SuperTable or Neo fields.

You might want to check out the Spoon plugin if you need nested Matrx support.

Joorren commented 3 years ago

Thanks for the answer!

Would you have any idea why it does work for the hero MatrixBlock, that's inside the contentBlocks MatrixBlock? That's the reason why I thought it should work for the other ones too 😛

mmikkel commented 3 years ago

Right, I didn't catch that detail in your original post 😅

If MatrixMate actually works for a Matrix field inside a SuperTable, that'd technically be a bug on our end, as we specifically designed and intended for MatrixMate to not initialise on any Matrix field nested in a different field.