edlptheme.theme 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @file
  4. * Functions to support theming in the edlp theme.
  5. */
  6. use Drupal\Core\Form\FormStateInterface;
  7. use Drupal\Core\Template\Attribute;
  8. // function edlptheme_preprocess_input(&$vars){
  9. // dsm($vars, 'vars');
  10. // $vars['attributes']['placeholder'] = "salut";
  11. // }
  12. function edlptheme_preprocess_node(&$vars){
  13. $node = $vars['elements']['#node'];
  14. $options = ['absolute' => TRUE];
  15. $url = \Drupal\Core\Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
  16. $system_path = $url->getInternalPath();
  17. $vars['link_attributes'] = new Attribute(array(
  18. 'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path
  19. ));
  20. }
  21. /**
  22. * Implements hook_form_alter
  23. */
  24. function edlptheme_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  25. // dpm($form_id, 'form_id');
  26. // dpm($form, 'form');
  27. $form['name']['#attributes']['placeholder'] = (string) $form['name']['#title'];
  28. unset($form['name']['#title']);
  29. $form['pass']['#attributes']['placeholder'] = (string) $form['pass']['#title'];
  30. unset($form['pass']['#title']);
  31. }
  32. function edlptheme_preprocess_edlp_productions(&$vars){
  33. foreach($vars['nodes'] as &$node){
  34. switch($node['vm']){
  35. case "image_2_columns":
  36. $cols = 4;
  37. break;
  38. case "image_1_columns":
  39. $cols = 2;
  40. break;
  41. case "text_1_column":
  42. $cols = 2;
  43. break;
  44. };
  45. $node['cols'] = $cols;
  46. }
  47. // dpm($vars);
  48. }