Add field_redirect_page to site_sections terms and fix root page hierarchy

- Add field_redirect_page to site_sections taxonomy terms, with a custom
  EntityReferenceSelection plugin that filters content_page nodes by section
- Redirect taxonomy term canonical URLs to the configured node (301)
- Fix root page detection in MenuBlock and views to also match nodes whose
  field_parent_page points to a taxonomy_term (not only empty parent)
- Move root taxonomy-term option to the top of the parent-page dropdown
- Add breadcrumb workaround for Gavias notech theme separator rendering
- Add imecc_menu_helper submodule
- Translate config labels and default terms from English to Portuguese

Co-Authored-By: Henrique Bauer <henrique@webcontent.com.br>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 07:52:49 -03:00
parent 36c3a2e9c0
commit 276fd028f2
26 changed files with 661 additions and 77 deletions

View File

@@ -410,6 +410,17 @@ function _structural_pages_alter_parent_page_form(&$form, \Drupal\Core\Form\Form
$default_parent = $current_entity->get('field_parent_page')->target_type . ':' . $current_entity->get('field_parent_page')->target_id;
}
// Add the Root (Taxonomy term) as the default option at the top of the tree.
$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($site_section_id);
$term_label = $term ? $term->label() : t('Taxonomia');
$root_key = 'taxonomy_term:' . $site_section_id;
$options = [$root_key => '< ' . t('Raiz (@term)', ['@term' => $term_label]) . ' >'] + $options;
if (empty($default_parent)) {
$default_parent = $root_key;
}
// Hide the original field.
$form['field_parent_page']['#access'] = FALSE;
@@ -419,8 +430,8 @@ function _structural_pages_alter_parent_page_form(&$form, \Drupal\Core\Form\Form
'#title' => t('Parent Page'),
'#options' => $options,
'#default_value' => $default_parent,
'#empty_option' => t('- Raiz da Seção -'),
'#description' => t('Select the parent page within this site section.'),
'#empty_option' => t('- Selecione a Página Pai -'),
'#description' => t('Select the parent page within this site section. Select Root if this is a top-level page.'),
// Attach a select2/chosen class if available in standard themes
'#attributes' => [
'class' => ['select2-widget', 'chosen-enable'],
@@ -468,12 +479,6 @@ function structural_pages_parent_page_ajax_callback(array &$form, \Drupal\Core\F
*/
function _structural_pages_build_parent_tree_options($site_section_id, $current_node_id = NULL) {
$options = [];
// Add the Section's Taxonomy Term as a Root option
$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($site_section_id);
if ($term) {
$options['taxonomy_term:' . $site_section_id] = '< Raiz (' . $term->getName() . ') >';
}
$query = \Drupal::entityQuery('node')
->condition('type', 'content_page')
@@ -581,7 +586,11 @@ function structural_pages_views_post_execute(\Drupal\views\ViewExecutable $view)
$query->condition('field_parent_page.target_type', 'node');
} else {
// Root page. Siblings are other root pages in the same site section.
$query->notExists('field_parent_page');
$orGroup = $query->orConditionGroup()
->notExists('field_parent_page')
->condition('field_parent_page.target_type', 'taxonomy_term');
$query->condition($orGroup);
if (!$current_node->get('field_site_section')->isEmpty()) {
$query->condition('field_site_section.target_id', $current_node->get('field_site_section')->target_id);
}