Loading auto_anchors.module +5 −0 Original line number Diff line number Diff line Loading @@ -18,8 +18,13 @@ function auto_anchors_page_attachments(array &$page) { 'root_elements' => $config->get('root_elements'), 'anchor_elements' => $config->get('anchor_elements'), 'link_content' => $config->get('link_content'), 'exclude_admin_pages' => $config->get('exclude_admin_pages'), ]; if ($settings['exclude_admin_pages'] and \Drupal::service('router.admin_context')->isAdminRoute()) { return; } $page['#attached']['library'][] = 'auto_anchors/auto_anchors'; $page['#attached']['drupalSettings']['auto_anchors'] = $settings; } Loading config/install/auto_anchors.settings.yml +1 −0 Original line number Diff line number Diff line root_elements: 'body' anchor_elements: 'h2, h3, h4, h5, h6' link_content: '#' exclude_admin_pages: true No newline at end of file config/schema/auto_anchor.schema.yml→config/schema/auto_anchors.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -11,3 +11,6 @@ auto_anchors.settings: link_content: type: string label: 'Link content' exclude_admin_pages: type: boolean label: 'Exclude admin pages' src/Form/SettingsForm.php +8 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,13 @@ class SettingsForm extends ConfigFormBase { '#default_value' => $config->get('link_content'), '#required' => TRUE, ]; $form['exclude_admin_pages'] = [ '#type' => 'checkbox', '#title' => $this->t('Exclude admin pages'), '#description' => $this->t('If checked, automatic ids and permalinks will not be generated on administrative pages.'), '#default_value' => $config->get('exclude_admin_pages'), '#required' => FALSE, ]; return parent::buildForm($form, $form_state); } Loading @@ -67,6 +74,7 @@ class SettingsForm extends ConfigFormBase { ->set('root_elements', $form_state->getValue('root_elements')) ->set('anchor_elements', $form_state->getValue('anchor_elements')) ->set('link_content', $form_state->getValue('link_content')) ->set('exclude_admin_pages', $form_state->getValue('exclude_admin_pages')) ->save(); } Loading Loading
auto_anchors.module +5 −0 Original line number Diff line number Diff line Loading @@ -18,8 +18,13 @@ function auto_anchors_page_attachments(array &$page) { 'root_elements' => $config->get('root_elements'), 'anchor_elements' => $config->get('anchor_elements'), 'link_content' => $config->get('link_content'), 'exclude_admin_pages' => $config->get('exclude_admin_pages'), ]; if ($settings['exclude_admin_pages'] and \Drupal::service('router.admin_context')->isAdminRoute()) { return; } $page['#attached']['library'][] = 'auto_anchors/auto_anchors'; $page['#attached']['drupalSettings']['auto_anchors'] = $settings; } Loading
config/install/auto_anchors.settings.yml +1 −0 Original line number Diff line number Diff line root_elements: 'body' anchor_elements: 'h2, h3, h4, h5, h6' link_content: '#' exclude_admin_pages: true No newline at end of file
config/schema/auto_anchor.schema.yml→config/schema/auto_anchors.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -11,3 +11,6 @@ auto_anchors.settings: link_content: type: string label: 'Link content' exclude_admin_pages: type: boolean label: 'Exclude admin pages'
src/Form/SettingsForm.php +8 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,13 @@ class SettingsForm extends ConfigFormBase { '#default_value' => $config->get('link_content'), '#required' => TRUE, ]; $form['exclude_admin_pages'] = [ '#type' => 'checkbox', '#title' => $this->t('Exclude admin pages'), '#description' => $this->t('If checked, automatic ids and permalinks will not be generated on administrative pages.'), '#default_value' => $config->get('exclude_admin_pages'), '#required' => FALSE, ]; return parent::buildForm($form, $form_state); } Loading @@ -67,6 +74,7 @@ class SettingsForm extends ConfigFormBase { ->set('root_elements', $form_state->getValue('root_elements')) ->set('anchor_elements', $form_state->getValue('anchor_elements')) ->set('link_content', $form_state->getValue('link_content')) ->set('exclude_admin_pages', $form_state->getValue('exclude_admin_pages')) ->save(); } Loading