preprocess class ressources
This commit is contained in:
+2
-1
@@ -62,7 +62,8 @@
|
||||
"cweagans/composer-patches": true,
|
||||
"drupal/core-composer-scaffold": true,
|
||||
"drupal/core-project-message": false,
|
||||
"wikimedia/composer-merge-plugin": true
|
||||
"wikimedia/composer-merge-plugin": true,
|
||||
"php-http/discovery": true
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
|
||||
+16
-129
@@ -7,7 +7,7 @@
|
||||
// use Drupal\Core\Template\Attribute;
|
||||
// use Drupal\Core\Link;
|
||||
// use Drupal\Core\Url;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
|
||||
function eql_preprocess_html(&$variables) {
|
||||
$node = \Drupal::routeMatch()->getParameter('node');
|
||||
@@ -21,7 +21,6 @@ function eql_preprocess_html(&$variables) {
|
||||
function eql_preprocess_node(&$variables){
|
||||
$node = &$variables['node'];
|
||||
$variables['attributes']['class'][] = 'node-type-' . $node->gettype();
|
||||
// $variables['elements']['content_bottom'] = []; /////////////////////////////
|
||||
if($node->gettype() == "actualite") {
|
||||
$actu_type = $node->get('field_actu_type')->getString();
|
||||
$variables['attributes']['class'][] = 'actu-type-' . $actu_type;
|
||||
@@ -30,17 +29,13 @@ function eql_preprocess_node(&$variables){
|
||||
$type_protagoniste = $node->get('field_type_de_protagoniste')->getString();
|
||||
$variables['attributes']['class'][] = 'type-de-protagoniste-' . $type_protagoniste;
|
||||
}
|
||||
|
||||
|
||||
// foreach ($variables['elements'] as $key => $value){ //////////////////////////////////
|
||||
// if(isset($value['#view_mode']) && $value['#view_mode']== 'teaser'){
|
||||
// if($value['elements']=="field_region" || $value['#derivative_plugin_id']=="node:field_adresse"){
|
||||
// $variables['elements']['content_bottom'][] = $variables["elements"]["field_incube"]["#field_name"];
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
// Vérifie si le champ field_type_de_ressource existe et ajoute une classe basée sur sa valeur
|
||||
if ($node->hasField('field_type_de_ressource') && !$node->get('field_type_de_ressource')->isEmpty()) {
|
||||
// Récupère la valeur de field_type_de_ressource
|
||||
$type_de_ressource = $node->get('field_type_de_ressource')->entity->getName();
|
||||
// Ajoute la classe CSS basée sur la valeur du type de ressource
|
||||
$variables['attributes']['class'][] = 'type-de-ressource-' . Html::cleanCssIdentifier($type_de_ressource);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -56,6 +51,13 @@ function eql_preprocess_field(&$variables) {
|
||||
$variables['attributes']['class'][] = 'type-de-protagoniste-' . $type_protagoniste;
|
||||
}
|
||||
}
|
||||
$field_name = &$variables['field_name'];
|
||||
if($node) {
|
||||
if ($field_name == 'field-type-de-ressource'){
|
||||
$type_ressource = $node->get('field-type-de-ressource')->getString();
|
||||
$variables['attributes']['class'][] = 'type-de-ressource-' . $type_ressource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +65,6 @@ function eql_preprocess_field(&$variables) {
|
||||
|
||||
function eql_preprocess_layout__threecol_25_50_25(&$variables) {
|
||||
$node = \Drupal::routeMatch()->getParameter('node');
|
||||
// $node = &$variables['node'];
|
||||
// $variables['attributes']['class'][] = 'node-type-' . $node->gettype();
|
||||
if($node->gettype() == "projet"){
|
||||
$variables['content']['top_bottom'] = []; /////// déclare les nvx array
|
||||
$variables['content']['top_right'] = [];
|
||||
@@ -79,9 +79,7 @@ function eql_preprocess_layout__threecol_25_50_25(&$variables) {
|
||||
if($value['#derivative_plugin_id']=="node:field_type_de_moa" || $value['#derivative_plugin_id']=="node:field_type_de_projet" || $value['#derivative_plugin_id']=="node:field_etape_du_projet") {
|
||||
$variables['content']['top_bottom'][] = $variables['content']['top'][$key];
|
||||
unset($variables["content"]["top"][$key]);
|
||||
}
|
||||
// foreach ($variables['content']['top_bottom'] as $key => $value) {
|
||||
// }
|
||||
}
|
||||
if($value['#derivative_plugin_id']=="node:title" || $value['#derivative_plugin_id']=="node:field_equipe" || $value['#derivative_plugin_id']=="node:field_incube"){
|
||||
$variables['content']['top_right'][] = $variables['content']['top'][$key];
|
||||
unset($variables["content"]["top"][$key]);
|
||||
@@ -95,115 +93,4 @@ function eql_preprocess_layout__threecol_25_50_25(&$variables) {
|
||||
}
|
||||
}
|
||||
|
||||
// function eql_preprocess_views_row_plugins(&$variables){
|
||||
// $t = 't';
|
||||
// }
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
// function eql_preprocess_input(&$variables) {
|
||||
// $form = \Drupal::routeMatch()->getParameter('form');
|
||||
|
||||
// $form['keys']['#attributes']['placeholder'] = t('The new placeholder');
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// function eql_preprocess_field(&$variables){
|
||||
// $node = &$variables['node'];
|
||||
// $variables['attributes']['class'][] = 'node-type-' . $node->gettype();
|
||||
// if($node->gettype() == "offre_de_service") {
|
||||
// $type_protagoniste = $node->get('field_type_de_protagoniste')->getString();
|
||||
// $variables['attributes']['class'][] = 'type-de-protagoniste-' . $type_protagoniste;
|
||||
// }
|
||||
// }
|
||||
|
||||
// function MYTHEME_preprocess_field__MYFIELD(&$variables) {
|
||||
|
||||
// if ($variables['element']['#entity_type'] === 'node') {
|
||||
// $node = $variables['element']['#object'];
|
||||
// $nid = $node->id();
|
||||
// $variables['myurl'] = \Drupal::service('path.alias_manager')->getAliasByPath('/node/' . $nid);
|
||||
// }
|
||||
// }
|
||||
|
||||
// function template_preprocess_block(&$variables) {
|
||||
// $node = &$variables['node'];
|
||||
// $variables['attributes']['class'][] = 'node-type-' . $node->gettype();
|
||||
// if($node->gettype() == "offre_de_service") {
|
||||
// $type_protagoniste = $node->get('field_type_de_protagoniste')->getString();
|
||||
// $variables['attributes']['class'][] = 'type-de-protagoniste-' . $type_protagoniste;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
// counter pour id
|
||||
|
||||
// function eql_preprocess_field(&$variables) {
|
||||
// // static $counter = 0;
|
||||
// // $variables['counter'] = $counter++;
|
||||
// $variables['elements']['#paragraph']->item_id;
|
||||
// }
|
||||
// la fonction suivante ne fonctionne pas
|
||||
// function eql_preprocess_field(&$variables) {
|
||||
|
||||
// $paragraph = &$variables['paragraph'];
|
||||
// $variables['attributes']['class'][] = 'paragraph-type-' . $paragraph->id();
|
||||
// $hook_id = $paragraph->get('paragraph-id--')->getString();
|
||||
// $variables['attributes']['class'][] = 'hook-id-' . $hook_id;
|
||||
// }
|
||||
//might be useful for if-clause: $variables['field_name'] and $variables['field_type']
|
||||
// if ($paragraph && $paragraph->getEntityTypeId() == 'paragraph' . $paragraph->id() ) {
|
||||
//whatever logic you need goes here, e.g. something like
|
||||
//$variables['attributes']['data-from-parent-paragraph'] = $parentEntity->getYourStuff();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// function yourtheme_preprocess_field(&$variables, $hook) {
|
||||
// $element = $variables['element'];
|
||||
// $parentEntity = $element['#object'];
|
||||
// //might be useful for if-clause: $variables['field_name'] and $variables['field_type']
|
||||
// if ($parentEntity && $parentEntity->getEntityTypeId() == 'paragraph' ) {
|
||||
// //whatever logic you need goes here, e.g. something like
|
||||
// //$variables['attributes']['data-from-parent-paragraph'] = $parentEntity->getYourStuff();
|
||||
// }
|
||||
// }
|
||||
|
||||
// $variables['elements']['#entity']->item_id;
|
||||
|
||||
// function MYTHEME_preprocess_views_view_fields__view_machine_name(&$vars) {
|
||||
// static $counter = 0;
|
||||
// $vars['counter'] = $counter++;
|
||||
// }
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
{#
|
||||
/**
|
||||
* @file
|
||||
* Theme override for a field.
|
||||
*
|
||||
* To override output, copy the "field.html.twig" from the templates directory
|
||||
* to your theme's directory and customize it, just like customizing other
|
||||
* Drupal templates such as page.html.twig or node.html.twig.
|
||||
*
|
||||
* Instead of overriding the theming for all fields, you can also just override
|
||||
* theming for a subset of fields using
|
||||
* @link themeable Theme hook suggestions. @endlink For example,
|
||||
* here are some theme hook suggestions that can be used for a field_foo field
|
||||
* on an article node type:
|
||||
* - field--node--field-foo--article.html.twig
|
||||
* - field--node--field-foo.html.twig
|
||||
* - field--node--article.html.twig
|
||||
* - field--field-foo.html.twig
|
||||
* - field--text-with-summary.html.twig
|
||||
* - field.html.twig
|
||||
*
|
||||
* Available variables:
|
||||
* - attributes: HTML attributes for the containing element.
|
||||
* - label_hidden: Whether to show the field label or not.
|
||||
* - title_attributes: HTML attributes for the title.
|
||||
* - label: The label for the field.
|
||||
* - multiple: TRUE if a field can contain multiple items.
|
||||
* - items: List of all the field items. Each item contains:
|
||||
* - attributes: List of HTML attributes for each item.
|
||||
* - content: The field item's content.
|
||||
* - entity_type: The entity type to which the field belongs.
|
||||
* - field_name: The name of the field.
|
||||
* - field_type: The type of the field.
|
||||
* - label_display: The display settings for the label.
|
||||
*
|
||||
*
|
||||
* @see template_preprocess_field()
|
||||
*/
|
||||
#}
|
||||
|
||||
{%
|
||||
set classes = [
|
||||
'field',
|
||||
'field--name-' ~ field_name|clean_class,
|
||||
'field--type-' ~ field_type|clean_class,
|
||||
'field--label-' ~ label_display,
|
||||
label_display == 'inline' ? 'clearfix',
|
||||
'block-' ~ plugin_id|clean_class,
|
||||
|
||||
|
||||
]
|
||||
%}
|
||||
{%
|
||||
set title_classes = [
|
||||
'field__label',
|
||||
label_display == 'visually_hidden' ? 'visually-hidden',
|
||||
]
|
||||
%}
|
||||
|
||||
{%
|
||||
set ouid_classes = [
|
||||
'first_part_home',
|
||||
]
|
||||
%}
|
||||
|
||||
|
||||
|
||||
|
||||
{% if label_hidden %}
|
||||
{% if multiple %}
|
||||
<div{{ attributes.addClass(classes, 'field__items') }}>
|
||||
{% for item in items %}
|
||||
<div{{ item.attributes.addClass('field__item') }}>{{ item.content }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% for item in items %}
|
||||
<div {{ attributes.addClass(classes, 'field__item') }}>{{ item.content }}</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
<div{{ title_attributes.addClass(title_classes) }}>{{ label }}</div>
|
||||
{% if multiple %}
|
||||
<div class="field__items">
|
||||
{% endif %}
|
||||
{% for item in items %}
|
||||
<div{{ item.attributes.addClass('field__item') }}>{{ item.content }}</div>
|
||||
{% endfor %}
|
||||
{% if multiple %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user