Skip to content

Instantly share code, notes, and snippets.

@stefansl
Last active October 13, 2015 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefansl/4153780 to your computer and use it in GitHub Desktop.
Save stefansl/4153780 to your computer and use it in GitHub Desktop.
Contao - limit subcolumn sets for user
/* Paste this into your /system/config/dcaconfig.php */
/* Configuration: which types of sets should be in the selectmenu? */
$allowed_gaptypes = array( '25x25x25x25','33x33x33','50x50' );
if (is_array($GLOBALS['TL_SUBCL'])) {
foreach ( $GLOBALS['TL_SUBCL'] as $set_key => $value)
{
foreach ( $GLOBALS['TL_SUBCL'][$set_key]['sets'] as $key => $value)
{
if ( in_array($key, $allowed_gaptypes) == FALSE ) {
unset($GLOBALS['TL_SUBCL'][$set_key]['sets'][$key]);
}
}
}
}
/* Autofill the gap with value 50 */
$GLOBALS['TL_DCA']['tl_content']['fields']['sc_gap']['default'] = '50';
@Hans-ChristianBenedict
Copy link

Excellent!

@Hans-ChristianBenedict
Copy link

$allowed_gaptypes = array( '20x20x20x20x20','25x25x25x25','33x33x33','50x50' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment