Skip to content
Snippets Groups Projects
Commit e8b226f8 authored by Hennie Martens's avatar Hennie Martens Committed by Greg Boggs
Browse files

Issue #3051863 by hmartens, Greg Boggs: Make Configuration options clearer

parent fef88507
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,12 @@ class EasyBreadcrumbGeneralSettingsForm extends ConfigFormBase { ...@@ -38,6 +38,12 @@ class EasyBreadcrumbGeneralSettingsForm extends ConfigFormBase {
'#open' => TRUE, '#open' => TRUE,
]; ];
$details_advanced = [
'#type' => 'details',
'#title' => $this->t('Advanced settings'),
'#open' => TRUE,
];
// If never set before ensure Applies to administration pages is on. // If never set before ensure Applies to administration pages is on.
$applies_admin_routes = $config->get(EasyBreadcrumbConstants::APPLIES_ADMIN_ROUTES); $applies_admin_routes = $config->get(EasyBreadcrumbConstants::APPLIES_ADMIN_ROUTES);
if (!isset($applies_admin_routes)) { if (!isset($applies_admin_routes)) {
...@@ -57,13 +63,6 @@ class EasyBreadcrumbGeneralSettingsForm extends ConfigFormBase { ...@@ -57,13 +63,6 @@ class EasyBreadcrumbGeneralSettingsForm extends ConfigFormBase {
'#default_value' => $config->get(EasyBreadcrumbConstants::INCLUDE_INVALID_PATHS), '#default_value' => $config->get(EasyBreadcrumbConstants::INCLUDE_INVALID_PATHS),
]; ];
$details_general[EasyBreadcrumbConstants::TITLE_FROM_PAGE_WHEN_AVAILABLE] = [
'#type' => 'checkbox',
'#title' => $this->t('Use the real page title when available'),
'#description' => $this->t('Use the real page title when it is available instead of always deducing it from the URL.'),
'#default_value' => $config->get(EasyBreadcrumbConstants::TITLE_FROM_PAGE_WHEN_AVAILABLE),
];
$details_general[EasyBreadcrumbConstants::INCLUDE_TITLE_SEGMENT] = [ $details_general[EasyBreadcrumbConstants::INCLUDE_TITLE_SEGMENT] = [
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => $this->t('Include the current page as a segment in the breadcrumb'), '#title' => $this->t('Include the current page as a segment in the breadcrumb'),
...@@ -92,11 +91,32 @@ class EasyBreadcrumbGeneralSettingsForm extends ConfigFormBase { ...@@ -92,11 +91,32 @@ class EasyBreadcrumbGeneralSettingsForm extends ConfigFormBase {
'#default_value' => $config->get(EasyBreadcrumbConstants::HOME_SEGMENT_TITLE), '#default_value' => $config->get(EasyBreadcrumbConstants::HOME_SEGMENT_TITLE),
]; ];
$details_general[EasyBreadcrumbConstants::TITLE_FROM_PAGE_WHEN_AVAILABLE] = [
'#type' => 'checkbox',
'#title' => $this->t('Use the real page title when available'),
'#description' => $this->t('Use the real page title when it is available instead of always deducing it from the URL.'),
'#default_value' => $config->get(EasyBreadcrumbConstants::TITLE_FROM_PAGE_WHEN_AVAILABLE),
];
$details_general[EasyBreadcrumbConstants::USE_MENU_TITLE_AS_FALLBACK] = [
'#type' => 'checkbox',
'#title' => $this->t('Use menu title when available'),
'#description' => $this->t('Use menu title instead of raw path component. The real page title setting above will take presidence over this setting. So, one or the other, but not both.'),
'#default_value' => $config->get(EasyBreadcrumbConstants::USE_MENU_TITLE_AS_FALLBACK),
];
$details_general[EasyBreadcrumbConstants::USE_PAGE_TITLE_AS_MENU_TITLE_FALLBACK] = [
'#type' => 'checkbox',
'#title' => $this->t('Use page title as fallback for menu title'),
'#description' => $this->t('Use page title as fallback if menu title cannot be found. This option works when not using "real page title" above.'),
'#default_value' => $config->get(EasyBreadcrumbConstants::USE_PAGE_TITLE_AS_MENU_TITLE_FALLBACK),
];
// Formats the excluded paths array as line separated list of paths // Formats the excluded paths array as line separated list of paths
// before displaying them. // before displaying them.
$excluded_paths = $config->get(EasyBreadcrumbConstants::EXCLUDED_PATHS); $excluded_paths = $config->get(EasyBreadcrumbConstants::EXCLUDED_PATHS);
$details_general[EasyBreadcrumbConstants::EXCLUDED_PATHS] = [ $details_advanced[EasyBreadcrumbConstants::EXCLUDED_PATHS] = [
'#type' => 'textarea', '#type' => 'textarea',
'#title' => $this->t('Paths to be excluded while generating segments'), '#title' => $this->t('Paths to be excluded while generating segments'),
'#description' => $this->t('Enter a line separated list of paths to be excluded while generating the segments. '#description' => $this->t('Enter a line separated list of paths to be excluded while generating the segments.
...@@ -108,7 +128,7 @@ class EasyBreadcrumbGeneralSettingsForm extends ConfigFormBase { ...@@ -108,7 +128,7 @@ class EasyBreadcrumbGeneralSettingsForm extends ConfigFormBase {
// before displaying them. // before displaying them.
$replaced_titles = $config->get(EasyBreadcrumbConstants::REPLACED_TITLES); $replaced_titles = $config->get(EasyBreadcrumbConstants::REPLACED_TITLES);
$details_general[EasyBreadcrumbConstants::REPLACED_TITLES] = [ $details_advanced[EasyBreadcrumbConstants::REPLACED_TITLES] = [
'#type' => 'textarea', '#type' => 'textarea',
'#title' => $this->t('Titles to be replaced while generating segments'), '#title' => $this->t('Titles to be replaced while generating segments'),
'#description' => $this->t('Enter a line separated list of titles with their replacements separated by ::.<br> '#description' => $this->t('Enter a line separated list of titles with their replacements separated by ::.<br>
...@@ -120,14 +140,14 @@ class EasyBreadcrumbGeneralSettingsForm extends ConfigFormBase { ...@@ -120,14 +140,14 @@ class EasyBreadcrumbGeneralSettingsForm extends ConfigFormBase {
// before displaying them. // before displaying them.
$custom_paths = $config->get(EasyBreadcrumbConstants::CUSTOM_PATHS); $custom_paths = $config->get(EasyBreadcrumbConstants::CUSTOM_PATHS);
$details_general[EasyBreadcrumbConstants::CUSTOM_PATHS] = [ $details_advanced[EasyBreadcrumbConstants::CUSTOM_PATHS] = [
'#type' => 'textarea', '#type' => 'textarea',
'#title' => $this->t('Paths to replace with custom breadcrumbs'), '#title' => $this->t('Paths to replace with custom breadcrumbs'),
'#description' => $this->t('Enter a line separated list of internal paths followed by breadcrumb pattern. Separate crumbs from their path with a vertical bar ("|"). Separate crumbs with double-colon ("::"). Omit the URL to display an unlinked crumb. Fields will be trimmed to remove extra start/end spaces, so you can use them to help format your input, if desired. Replaced Titles will not be processed on custom paths. Excluded paths listed here will have breadcrumbs added. Examples (with and without extra spacing):<br><code>/news/archive/site_launched :: News|/news :: Archive | /news/archive :: Site Launched<br>/your/path::LinkedCrumb1|url1::LinkedCrumb2|url2::UnlinkedCrumb3</code><br>'), '#description' => $this->t('Enter a line separated list of internal paths followed by breadcrumb pattern. Separate crumbs from their path with a vertical bar ("|"). Separate crumbs with double-colon ("::"). Omit the URL to display an unlinked crumb. Fields will be trimmed to remove extra start/end spaces, so you can use them to help format your input, if desired. Replaced Titles will not be processed on custom paths. Excluded paths listed here will have breadcrumbs added. Examples (with and without extra spacing):<br><code>/news/archive/site_launched :: News|/news :: Archive | /news/archive :: Site Launched<br>/your/path::LinkedCrumb1|url1::LinkedCrumb2|url2::UnlinkedCrumb3</code><br>'),
'#default_value' => $custom_paths, '#default_value' => $custom_paths,
]; ];
$details_general[EasyBreadcrumbConstants::HOME_SEGMENT_KEEP] = [ $details_advanced[EasyBreadcrumbConstants::HOME_SEGMENT_KEEP] = [
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => $this->t('Display the front page segment on the front page'), '#title' => $this->t('Display the front page segment on the front page'),
'#description' => $this->t('If checked, the Home segment will be displayed on the front page.'), '#description' => $this->t('If checked, the Home segment will be displayed on the front page.'),
...@@ -139,59 +159,46 @@ class EasyBreadcrumbGeneralSettingsForm extends ConfigFormBase { ...@@ -139,59 +159,46 @@ class EasyBreadcrumbGeneralSettingsForm extends ConfigFormBase {
], ],
]; ];
$details_general[EasyBreadcrumbConstants::TITLE_SEGMENT_AS_LINK] = [ $details_advanced[EasyBreadcrumbConstants::TITLE_SEGMENT_AS_LINK] = [
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => $this->t('Make the page title segment a link'), '#title' => $this->t('Make the current page title segment a link'),
'#description' => $this->t('Prints the page title segment as a link. This option works together with the "Include the current page as a segment in the breadcrumb"-option.'), '#description' => $this->t('Prints the page title segment as a link. This option works together with the "Include the current page as a segment in the breadcrumb"-option.'),
'#default_value' => $config->get(EasyBreadcrumbConstants::TITLE_SEGMENT_AS_LINK), '#default_value' => $config->get(EasyBreadcrumbConstants::TITLE_SEGMENT_AS_LINK),
]; ];
$details_general[EasyBreadcrumbConstants::LANGUAGE_PATH_PREFIX_AS_SEGMENT] = [ $details_advanced[EasyBreadcrumbConstants::LANGUAGE_PATH_PREFIX_AS_SEGMENT] = [
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => $this->t('Make the language path prefix a segment'), '#title' => $this->t('Make the language path prefix a segment'),
'#description' => $this->t('On multilingual sites where a path prefix ("/en") is used, add this in the breadcrumb.'), '#description' => $this->t('On multilingual sites where a path prefix ("/en") is used, add this in the breadcrumb.'),
'#default_value' => $config->get(EasyBreadcrumbConstants::LANGUAGE_PATH_PREFIX_AS_SEGMENT), '#default_value' => $config->get(EasyBreadcrumbConstants::LANGUAGE_PATH_PREFIX_AS_SEGMENT),
]; ];
$details_general[EasyBreadcrumbConstants::USE_MENU_TITLE_AS_FALLBACK] = [ $details_advanced[EasyBreadcrumbConstants::ABSOLUTE_PATHS] = [
'#type' => 'checkbox',
'#title' => $this->t('Use menu title as fallback'),
'#description' => $this->t('Use menu title as fallback instead of raw path component.'),
'#default_value' => $config->get(EasyBreadcrumbConstants::USE_MENU_TITLE_AS_FALLBACK),
];
$details_general[EasyBreadcrumbConstants::USE_PAGE_TITLE_AS_MENU_TITLE_FALLBACK] = [
'#type' => 'checkbox',
'#title' => $this->t('Use page title as fallback for menu title'),
'#description' => $this->t('Use page title as fallback if menu title cannot be found (this does not make sense in conjunction with Use the real page title when available).'),
'#default_value' => $config->get(EasyBreadcrumbConstants::USE_PAGE_TITLE_AS_MENU_TITLE_FALLBACK),
];
$details_general[EasyBreadcrumbConstants::ABSOLUTE_PATHS] = [
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => $this->t('Use absolute path for Breadcrumb links'), '#title' => $this->t('Use absolute path for Breadcrumb links'),
'#description' => $this->t('By selecting, absolute paths will be used (default: false) instead of relative.'), '#description' => $this->t('By selecting, absolute paths will be used (default: false) instead of relative.'),
'#default_value' => $config->get(EasyBreadcrumbConstants::ABSOLUTE_PATHS), '#default_value' => $config->get(EasyBreadcrumbConstants::ABSOLUTE_PATHS),
]; ];
$details_general[EasyBreadcrumbConstants::HIDE_SINGLE_HOME_ITEM] = [ $details_advanced[EasyBreadcrumbConstants::HIDE_SINGLE_HOME_ITEM] = [
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => $this->t("Hide link to home page if it's the only breadcrumb item"), '#title' => $this->t("Hide link to home page if it's the only breadcrumb item"),
'#description' => $this->t('Hide the breadcrumb when it only links to the home page and nothing more.'), '#description' => $this->t('Hide the breadcrumb when it only links to the home page and nothing more.'),
'#default_value' => $config->get(EasyBreadcrumbConstants::HIDE_SINGLE_HOME_ITEM), '#default_value' => $config->get(EasyBreadcrumbConstants::HIDE_SINGLE_HOME_ITEM),
]; ];
$details_general[EasyBreadcrumbConstants::TERM_HIERARCHY] = [ $details_advanced[EasyBreadcrumbConstants::TERM_HIERARCHY] = [
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => $this->t('Use term hierarchy.'), '#title' => $this->t('Add parent hierarchy'),
'#description' => $this->t('Show in breadcrumb all parent for current term.'), '#description' => $this->t('Add all taxonomy parents in the crumb for current term.'),
'#default_value' => $config->get(EasyBreadcrumbConstants::TERM_HIERARCHY), '#default_value' => $config->get(EasyBreadcrumbConstants::TERM_HIERARCHY),
]; ];
$form = []; $form = [];
// Inserts the details for grouping general settings fields. // Inserts the details for grouping general settings fields.
$form[EasyBreadcrumbConstants::MODULE_NAME] = $details_general; $form[EasyBreadcrumbConstants::MODULE_NAME][] = $details_general;
$form[EasyBreadcrumbConstants::MODULE_NAME][] = $details_advanced;
return parent::buildForm($form, $form_state); return parent::buildForm($form, $form_state);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment