Skip to content

Commit

Permalink
[4.1] Parameters for Module Chromes (#23577)
Browse files Browse the repository at this point in the history
* Loading chrome specific form files from chrome folders

* Use Form instead of JForm
Skip template if chrome folder doesn't exist

* Move module style field to bottom so it's next to the chrome parameters

* Update administrator/components/com_modules/src/Model/ModuleModel.php

Co-authored-by: Richard Fath <richard67@users.noreply.github.com>

Co-authored-by: Thomas Hunziker <werbemails@bakual.ch>
Co-authored-by: Benjamin Trenkle <bembelimen@users.noreply.github.com>
Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
  • Loading branch information
4 people committed Nov 9, 2021
1 parent 6121d25 commit 16cf06a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
12 changes: 6 additions & 6 deletions administrator/components/com_modules/forms/advanced.xml
Expand Up @@ -4,12 +4,6 @@
<fieldset
name="advanced">

<field
name="style"
type="chromestyle"
label="COM_MODULES_FIELD_MODULE_STYLE_LABEL"
/>

<field
name="module_tag"
type="moduletag"
Expand Down Expand Up @@ -42,6 +36,12 @@
rows="3"
validate="CssIdentifier"
/>

<field
name="style"
type="chromestyle"
label="COM_MODULES_FIELD_MODULE_STYLE_LABEL"
/>
</fieldset>
</fields>
</form>
42 changes: 42 additions & 0 deletions administrator/components/com_modules/src/Model/ModuleModel.php
Expand Up @@ -14,6 +14,7 @@
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Helper\ModuleHelper;
Expand All @@ -23,6 +24,7 @@
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Table\Table;
use Joomla\Component\Modules\Administrator\Helper\ModulesHelper;
use Joomla\Database\ParameterType;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
Expand Down Expand Up @@ -900,6 +902,46 @@ protected function preprocessForm(Form $form, $data, $group = 'content')
Form::addFormPath(JPATH_ADMINISTRATOR . '/components/com_modules/models/forms');
$form->loadFile('advanced', false);

// Load chrome specific params for global files
$chromePath = JPATH_SITE . '/layouts/chromes';
$chromeFormFiles = Folder::files($chromePath, '.*\.xml');

if ($chromeFormFiles)
{
Form::addFormPath($chromePath);

foreach ($chromeFormFiles as $formFile)
{
$form->loadFile(basename($formFile, '.xml'), false);
}
}

// Load chrome specific params for template files
$templates = ModulesHelper::getTemplates($clientId);

foreach ($templates as $template)
{
$chromePath = $client->path . '/templates/' . $template->element . '/html/layouts/chromes';

// Skip if there is no chrome folder in that template.
if (!is_dir($chromePath))
{
continue;
}

$chromeFormFiles = Folder::files($chromePath, '.*\.xml');

if ($chromeFormFiles)
{
Form::addFormPath($chromePath);

foreach ($chromeFormFiles as $formFile)
{
$form->loadFile(basename($formFile, '.xml'), false);
}
}
}

// Trigger the default form events.
parent::preprocessForm($form, $data, $group);
}
Expand Down

0 comments on commit 16cf06a

Please sign in to comment.