-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
860 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,88 @@ | ||
# contao-config-driver | ||
# Config Driver for Contao Open Source CMS | ||
|
||
This extension adds another driver to the Contao Open Source CMS. | ||
|
||
With the Config-Driver it is possible to load fields from a configuration file and output them in the backend. The DCA structure used by Contao is kept. It can be decided whether the data is stored in the localconfig or in an existing database column. | ||
|
||
For the storage in an existing database column, all fields of the configuration file are stored serialized. | ||
|
||
### Example for saving in localconfig: | ||
``` | ||
$GLOBALS['TL_DCA']['tl_newdca'] = array | ||
( | ||
'config' => array | ||
( | ||
'dataContainer' => 'Config', | ||
'configFile' => 'dcaConfigFile' // Configuration-File: /templates/dcaConfigFile.php | ||
) | ||
); | ||
``` | ||
|
||
### Example for saving in existing database table/column: | ||
|
||
``` | ||
$GLOBALS['TL_DCA']['tl_newdca'] = array | ||
( | ||
'config' => array | ||
( | ||
'dataContainer' => 'Config', | ||
'ptable' => 'tl_theme', // Table | ||
'configField' => 'configData', // Column | ||
'configFile' => 'dcaConfigFile' // Configuration-File: /templates/dcaConfigFile.php | ||
) | ||
); | ||
``` | ||
|
||
### Example of a configuration file | ||
``` | ||
return array( | ||
'palettes' => array( // | ||
'default' => '{font_legend},fontsize,fontcolor' // Optional | ||
), // | ||
'fields' => array( | ||
'fontsize' => array | ||
( | ||
'label' => &$GLOBALS['TL_LANG']['tl_newdca']['fontsize'], | ||
'inputType' => 'inputUnit', | ||
'options' => $GLOBALS['TL_CSS_UNITS'], | ||
'eval' => array('includeBlankOption'=>true, 'rgxp'=>'digit_inherit', 'maxlength' => 20, 'tl_class'=>'w50'), | ||
), | ||
'fontcolor' => array | ||
( | ||
'label' => &$GLOBALS['TL_LANG']['tl_newdca']['fontcolor'], | ||
'inputType' => 'text', | ||
'eval' => array('maxlength'=>6, 'colorpicker'=>true, 'isHexColor'=>true, 'decodeEntities'=>true, 'tl_class'=>'w50 wizard'), | ||
) | ||
) | ||
); | ||
``` | ||
|
||
### Further Examples | ||
To continue the example from above and to be able to call the configuration in the backend via the themes, we can add another icon for each theme. | ||
##### config/config.php | ||
``` | ||
$GLOBALS['BE_MOD']['design']['themes']['tables'][] = 'tl_newdca'; | ||
``` | ||
|
||
##### dca/tl_theme.php | ||
``` | ||
// Add operation | ||
$GLOBALS['TL_DCA']['tl_theme']['list']['operations']['newdca'] = array | ||
( | ||
'label' => &$GLOBALS['TL_LANG']['tl_theme']['newdca'], | ||
'href' => 'table=tl_newdca', | ||
'icon' => 'css.svg', | ||
); | ||
// Add fields | ||
$GLOBALS['TL_DCA']['tl_theme']['fields']['configData'] = array | ||
( | ||
'inputType' => 'text', | ||
'sql' => "text NULL" | ||
); | ||
``` | ||
|
||
##### Backend View | ||
![Admin View: List](https://www.oveleon.de/share/github-assets/contao-config-driver-bundle/config-driver-example.png) | ||
|
||
Now we can edit the configuration and use it as we like. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name":"oveleon/contao-config-driver-bundle", | ||
"type":"contao-bundle", | ||
"description":"Config Driver for Contao Open Source CMS", | ||
"keywords":["contao","driver","config"], | ||
"homepage":"https://www.oveleon.de/", | ||
"license":"MIT", | ||
"authors":[ | ||
{ | ||
"name":"Oveleon", | ||
"homepage":"https://oveleon.de/", | ||
"role":"Developer" | ||
} | ||
], | ||
"require":{ | ||
"php":"^5.6 || ^7.0", | ||
"contao/core-bundle":"^4.4" | ||
}, | ||
"require-dev": { | ||
"contao/manager-plugin": "^2.0" | ||
}, | ||
"conflict": { | ||
"contao/core": "*", | ||
"contao/core-bundle": "4.4.1", | ||
"contao/manager-plugin": "<2.0 || >=3.0" | ||
}, | ||
"autoload":{ | ||
"psr-4": { | ||
"Oveleon\\ContaoConfigDriverBundle\\": "src/" | ||
}, | ||
"classmap": [ | ||
"src/Resources/contao/" | ||
], | ||
"exclude-from-classmap": [ | ||
"src/Resources/contao/config/", | ||
"src/Resources/contao/dca/", | ||
"src/Resources/contao/languages/", | ||
"src/Resources/contao/templates/" | ||
] | ||
}, | ||
"extra":{ | ||
"contao-manager-plugin": "Oveleon\\ContaoConfigDriverBundle\\ContaoManager\\Plugin" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Contao Config Driver Bundle. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
namespace Oveleon\ContaoConfigDriverBundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class ContaoConfigDriverBundle extends Bundle | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Contao Config Driver Bundle. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
namespace Oveleon\ContaoConfigDriverBundle\ContaoManager; | ||
|
||
use Contao\CoreBundle\ContaoCoreBundle; | ||
use Contao\ManagerPlugin\Bundle\BundlePluginInterface; | ||
use Contao\ManagerPlugin\Bundle\Config\BundleConfig; | ||
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; | ||
use Oveleon\ContaoConfigDriverBundle\ContaoConfigDriverBundle; | ||
|
||
class Plugin implements BundlePluginInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getBundles(ParserInterface $parser): array | ||
{ | ||
return [ | ||
BundleConfig::create(ContaoConfigDriverBundle::class) | ||
->setLoadAfter([ContaoCoreBundle::class]) | ||
->setReplace(['config-driver']), | ||
]; | ||
} | ||
} |
Oops, something went wrong.