PHP code example of vaersaagod / matrixmate
1. Go to this page and download the library: Download vaersaagod/matrixmate library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vaersaagod / matrixmate example snippets
return [
'fields' => [
'matrixFieldHandle' => [
'groups' => [[
'label' => 'Content',
'types' => ['text', 'images', 'video'],
], [
'label' => 'Listings',
'types' => ['news', 'employees'],
]],
'types' => [
'text' => [
'tabs' => [[
'label' => 'Text',
'fields' => ['heading', 'text'],
], [
'label' => 'Settings',
'fields' => ['columns'],
]],
'hiddenFields' => ['backgroundColor', 'textColor'],
],
'news' => [
'maxLimit' => 1,
],
],
],
'anotherMatrixFieldHandle' => [
...
],
],
];
return [
'fields' => [
'matrixFieldHandle' => [
'*' => [
'groups' => [
...
],
],
'section:news,section:blog' => [
'groups' => [
...
],
],
],
],
];
$globalConfig = [
'groups' => [
...
],
];
return [
'fields' => [
'matrixFieldHandle' => [
'*' => $globalConfig,
'section:news,section:blog' => array_merge_recursive($globalConfig, [
'groups' => [
...
],
]),
],
],
];
return [
'fields' => [
'matrixFieldHandle' => [
// Field configuration here
],
],
];
return [
'fields' => [
'matrixFieldHandle' => [
'defaultTabName' => 'Misc',
],
],
];
return [
'fields' => [
'matrixFieldHandle' => [
'defaultTabName' => false,
],
],
];
return [
'fields' => [
'matrixFieldHandle' => [
...
'defaultTabName' => 'Misc',
'defaultTabFirst' => true,
],
],
];
...
'matrixFieldHandle' => [
'groups' => [[
'label' => 'Content',
'types' => ['text', 'heading'],
], [
'label' => 'Misc',
'types' => ['newsletter', 'feed'],
]],
],
...
'matrixFieldHandle' => [
'types' => [
'text' => [
// Block type config here
],
'news' => [
// Block type config here
],
],
],
...
'types' => [
'text' => [
'tabs' => [[
'label' => 'Content',
'fields' => ['heading', 'text'],
], [
'label' => 'Settings',
'fields' => ['columns'],
]],
],
],
...
'types' => [
'text' => [
'tabs' => [[
'label' => 'Content',
'fields' => ['heading', 'text'],
], [
'label' => 'Settings',
'fields' => ['columns'],
]],
'defaultTabName' => 'Misc',
],
],
...
'types' => [
'text' => [
'tabs' => [[
'label' => 'Content',
'fields' => ['heading', 'text'],
], [
'label' => 'Settings',
'fields' => ['columns'],
]],
'defaultTabName' => false,
],
],
...
'types' => [
...
'news' => [
'maxLimit' => 1,
],
],
...
'types' => [
...
'text' => [
'hiddenFields' => ['backgroundColor', 'textColor'],
],
],
...
'matrixFieldHandle' => [
'groups' => [...],
'hideUngroupedTypes' => true,
],
...
'matrixFieldHandle' => [
'hiddenTypes' => ['newsletter', 'feed'],
],
...
'matrixFieldHandle' => [
'groups' => [...],
'ungroupedTypesPosition' => 'after',
],
$isUserAdmin = Craft::$app->getUser()->admin;
return [
'fields' => [
'matrixFieldHandle' => [
...
'section:news,section:blog' => !$isUserAdmin ? [
'groups' => [
...
],
] : null,
],
],
];
$isCpRequest = \explode('/', \parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))[1] ?? null === 'admin';
return [
'*' => [
...
'disabledPlugins' => \array_filter([!$isCpRequest ? 'matrixmate' : null]),
],
...
];