materio-d9/web/themes/custom/matminimal/matminimal.theme

66 lines
2.3 KiB
Plaintext
Raw Permalink Normal View History

<?php
/**
* @file
* Functions to support theming in the Seven theme.
*/
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_preprocess_HOOK() for HTML document templates.
*/
// function matminimal_preprocess_html(&$variables) {
// // If on a node add or edit page, add a node-layout class.
// $path_args = explode('/', \Drupal::request()->getPathInfo());
// if ($suggestions = theme_get_suggestions($path_args, 'page', '-')) {
// foreach ($suggestions as $suggestion) {
// // dsm($suggestion);
// preg_match('/taxonomy-manage-[^-]+-add$/', $suggestion, $matches);
// // ksm($matches);
// if ($suggestion === 'page--taxonomy-term-edit' || isset($matches)) {
// $variables['attributes']['class'][] = 'node-form-layout';
// }
// }
// }
// }
// function matminimal_form_alter(&$form, FormStateInterface $form_state, $form_id){
// // dsm($form_id);
// // create a colomuned term form (not working yet)
// if(in_array($form_id, ['taxonomy_term_company_form', 'taxonomy_term_showroom_form'])){
// // ksm($form);
// $form['#theme'] = ['term_edit_form'];
// $form['#attached']['library'][] = 'seven/node-form';
//
// $form['advanced']['#type'] = 'container';
// $form['meta']['#type'] = 'container';
// $form['meta']['#access'] = TRUE;
// $form['meta']['changed']['#wrapper_attributes']['class'][] = 'container-inline';
// $form['meta']['author']['#wrapper_attributes']['class'][] = 'container-inline';
//
// $form['revision_information']['#type'] = 'container';
// $form['revision_information']['#group'] = 'meta';
// }
// }
/**
* Implements hook_form_BASE_FORM_ID_alter() for \Drupal\node\NodeForm.
*
* Changes vertical tabs to container.
*/
function matminimal_form_node_form_alter(&$form, FormStateInterface $form_state) {
$form['#theme'] = ['node_edit_form'];
$form['#attached']['library'][] = 'seven/node-form';
$form['advanced']['#type'] = 'container';
$form['meta']['#type'] = 'container';
$form['meta']['#access'] = TRUE;
$form['meta']['changed']['#wrapper_attributes']['class'][] = 'container-inline';
$form['meta']['author']['#wrapper_attributes']['class'][] = 'container-inline';
$form['revision_information']['#type'] = 'container';
$form['revision_information']['#group'] = 'meta';
}