Skip to content

Commit

Permalink
allow custom redirect page
Browse files Browse the repository at this point in the history
  • Loading branch information
coastforge-fsc committed Oct 12, 2023
1 parent fe5b7b3 commit 633f6f6
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/Classes/Contao/Callbacks/ModuleCallback.php
Expand Up @@ -98,7 +98,21 @@ public function loadAvailableFieldsNonEditableOptions($dc)

return $options;
}
public function getFieldForRedirect ($dc) {
$options = [
'id' => "id"
];
$customFields = DataCustomFieldModel::findAll();
foreach ($customFields as $customField) {
$label = strval($customField->name);
if (strval($customField->description) !== '') {
$label .= " <sup title='" . strval($customField->description) . "'>(?)</sup>";
}
$options[strval($customField->alias)] = $label;
}

return $options;
}
public function loadOrderByFieldsOptions($dc)
{
System::loadLanguageFile('tl_c4g_data_element');
Expand Down
7 changes: 6 additions & 1 deletion src/Controller/PublicNonEditableController.php
Expand Up @@ -580,7 +580,12 @@ public function addFields() : array
false, true, true, false)
->setShowIfEmpty(false)
->setHidden();

if ($this->model->redirectPage) {
$fieldList[] = C4GLinkButtonField::create('link')
->setTargetPageId($this->model->redirectPage)
->setButtonLabel($GLOBALS['TL_LANG']['con4gis']['data']['frontend']['redirect'])
->setTargetModifier($this->model->fieldForRedirect);
}
if ($this->model->mapPage) {
$fieldList[] = C4GMapLinkButtonField::create('maplink')
->setTargetPageId($this->model->mapPage)
Expand Down
22 changes: 21 additions & 1 deletion src/Resources/contao/dca/tl_module.php
Expand Up @@ -29,7 +29,7 @@

$GLOBALS['TL_DCA']['tl_module']['palettes'][PublicNonEditableController::TYPE] = '{title_legend},name,headline,type;{caption_legend},'.
'captionPlural,caption;{c4g_data_type_legend},c4g_data_mode,showSelectFilter,selectFilterLabel,showDirectorySelectFilter,directorySelectFilterLabel,labelMode,showFilterResetButton,'.
'filterResetButtonCaption;{c4g_expert_legend},hideDetails,showLabelsInList,phoneLabel,mobileLabel,faxLabel,emailLabel,websiteLabel,availableFieldsList,c4g_order_by_fields;{mapPage_legend},mapPage';
'filterResetButtonCaption;{c4g_expert_legend},hideDetails,showLabelsInList,phoneLabel,mobileLabel,faxLabel,emailLabel,websiteLabel,availableFieldsList,c4g_order_by_fields;{mapPage_legend},mapPage,redirectPage,fieldForRedirect';

$GLOBALS['TL_DCA']['tl_module']['subpalettes']['c4g_data_mode_0'] = '';
$GLOBALS['TL_DCA']['tl_module']['subpalettes']['c4g_data_mode_1'] = 'c4g_data_type';
Expand Down Expand Up @@ -77,6 +77,13 @@
'inputType' => 'pageTree',
'sql' => "int(10) unsigned NOT NULL default '0'"
];
$GLOBALS['TL_DCA']['tl_module']['fields']['redirectPage'] =
[
'label' => &$GLOBALS['TL_LANG']['tl_module']['redirectPage'],
'exclude' => true,
'inputType' => 'pageTree',
'sql' => "int(10) unsigned NOT NULL default '0'"
];

$GLOBALS['TL_DCA']['tl_module']['fields']['caption'] =
[
Expand Down Expand Up @@ -296,6 +303,19 @@
'sql' => "text NOT NULL default ".serialize(['name'])
];

$GLOBALS['TL_DCA']['tl_module']['fields']['fieldForRedirect'] =
[
'label' => &$GLOBALS['TL_LANG']['tl_module']['fieldForRedirect'],
'exclude' => true,
'default' => serialize(['name']),
'options_callback' => [$cbClass, 'getFieldForRedirect'],
'inputType' => 'select',
'eval' => [
'class' => 'clr',
],
'sql' => "text NOT NULL default ''"
];

$GLOBALS['TL_DCA']['tl_module']['fields']['authorizedGroups'] =
[
'label' => &$GLOBALS['TL_LANG']['tl_module']['authorizedGroups'],
Expand Down
1 change: 1 addition & 0 deletions src/Resources/contao/languages/de/tl_c4g_data_element.php
Expand Up @@ -146,5 +146,6 @@
$GLOBALS['TL_LANG']['con4gis']['data']['frontend']['email'] = 'E-Mail';
$GLOBALS['TL_LANG']['con4gis']['data']['frontend']['website'] = 'Website';
$GLOBALS['TL_LANG']['con4gis']['data']['frontend']['toMap'] = 'zur Karte';
$GLOBALS['TL_LANG']['con4gis']['data']['frontend']['redirect'] = 'Details';


2 changes: 2 additions & 0 deletions src/Resources/contao/languages/de/tl_module.php
Expand Up @@ -24,6 +24,8 @@
$GLOBALS['TL_LANG']['tl_module']['c4g_data_type'] = ['Kategorie', 'Nur Elemente dieser Kategorie werden angezeigt.'];
$GLOBALS['TL_LANG']['tl_module']['c4g_data_directory'] = ['Verzeichnis', 'Nur Elemente in Kategorien aus diesem Verzeichnis werden angezeigt.'];
$GLOBALS['TL_LANG']['tl_module']['mapPage'] = ['Kartenseite', ''];
$GLOBALS['TL_LANG']['tl_module']['redirectPage'] = ['Weiterleitungsseite', ''];
$GLOBALS['TL_LANG']['tl_module']['fieldForRedirect'] = ['Identifier für Weiterleitung', ''];
$GLOBALS['TL_LANG']['tl_module']['captionPlural'] = ['Listentitel', 'Der Titel oberhalb der Liste.'];
$GLOBALS['TL_LANG']['tl_module']['caption'] = ['Detailtitel', 'Der Titel oberhalb der Listendetails.'];
$GLOBALS['TL_LANG']['tl_module']['showSelectFilter'] = ['Zeige Kategoriefilter in der Liste', 'Falls gesetzt, wird über der Liste ein Filterfeld angezeigt, mit dem der Nutzer die Liste nach Kategorie filtern kann.'];
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/contao/languages/en/tl_c4g_data_element.php
Expand Up @@ -145,4 +145,4 @@
$GLOBALS['TL_LANG']['con4gis']['data']['frontend']['fax'] = 'Fax';
$GLOBALS['TL_LANG']['con4gis']['data']['frontend']['email'] = 'E-Mail';
$GLOBALS['TL_LANG']['con4gis']['data']['frontend']['website'] = 'Website';
$GLOBALS['TL_LANG']['con4gis']['data']['frontend']['toMap'] = 'go to Map';
$GLOBALS['TL_LANG']['con4gis']['data']['frontend']['toMap'] = 'details';
2 changes: 2 additions & 0 deletions src/Resources/contao/languages/en/tl_module.php
Expand Up @@ -24,6 +24,8 @@
$GLOBALS['TL_LANG']['tl_module']['c4g_data_type'] = ['Category', 'Only elements of this category will be displayed'];
$GLOBALS['TL_LANG']['tl_module']['c4g_data_directory'] = ['Directory', 'Only items in categories from this directory will be displayed'];
$GLOBALS['TL_LANG']['tl_module']['mapPage'] = ['map page', ''];
$GLOBALS['TL_LANG']['tl_module']['redirectPage'] = ['Redirect Page', ''];
$GLOBALS['TL_LANG']['tl_module']['fieldForRedirect'] = ['Identifier for redirect', ''];
$GLOBALS['TL_LANG']['tl_module']['captionPlural'] = ['list title', 'The title above the list.'];
$GLOBALS['TL_LANG']['tl_module']['caption'] = ['DetailTitle', 'The title above the list details.'];
$GLOBALS['TL_LANG']['tl_module']['showSelectFilter'] = ['Show category filter in list', 'If set, a filter field will be displayed above the list, allowing the user to filter the list by category.'];
Expand Down

0 comments on commit 633f6f6

Please sign in to comment.