From 38bcce6c82ec164f7b520ca6fdeb3ce6edbe0570 Mon Sep 17 00:00:00 2001 From: bach Date: Thu, 26 Aug 2021 21:58:14 +0200 Subject: [PATCH] deactivated popsu_monde links, sass needs to be compiled --- web/themes/custom/popsu/popsu.theme | 96 ++++++++++++------- .../sass/pages/partials/_header_footer.scss | 2 +- 2 files changed, 62 insertions(+), 36 deletions(-) diff --git a/web/themes/custom/popsu/popsu.theme b/web/themes/custom/popsu/popsu.theme index 9f6fde37..0a88db55 100644 --- a/web/themes/custom/popsu/popsu.theme +++ b/web/themes/custom/popsu/popsu.theme @@ -5,7 +5,8 @@ */ use Drupal\Core\Template\Attribute; - +use Drupal\Core\Link; +use Drupal\Core\Url; // function popsu_preprocess_views_view_list(&$variables){ // kint($variables);die(); @@ -133,48 +134,73 @@ function popsu_preprocess_views_view_grid(&$variables){ } function popsu_preprocess_views_view_field(&$variables){ - // check if link to entoty option is true + // check if link to entity option is true $settings = isset($variables['field']->options['settings']) ? $variables['field']->options['settings'] : false; if ($settings && isset($settings['link_to_entity']) && $settings['link_to_entity']) { // get the entity and build the classes $entity = $variables['row']->_entity; + // $entity_type = $entity->getEntityType(); + if ($entity->getEntityType()->id() == "node" && $entity->id() == 5) { + // temporarely desactivate popsumonde link + // get the entity link and url + $link = $entity->toLink(); - // build new classes - $new_classes = array( - $entity->getEntityTypeId(), - $entity->getEntityTypeId().'-'.$entity->bundle(), - $entity->getEntityTypeId().'-'.$entity->bundle().'-'.$entity->id(), - ); - - - - // get the entity link and url - $link = $entity->toLink(); - $url = $entity->toLink()->getUrl(); - - // set the active_class option to the url - $url->setOption('set_active_class', true); - - // add new classes to the url (without overwriting existing once) - $options = $url->getOptions(); - if(isset($options['attributes']) && $attributes = $options['attributes']){ - if(isset($attributes['class']) && $classes = $attributes['class']){ - $attributes['class'] += $new_classes; - }else{ - $attributes['class'] = $new_classes; - } + // // $url = $entity->toLink()->getUrl(); + // $url = URL::fromUserInput('#'); + // // update the url of the link + // $link->setUrl($url); + + // overwrite the output + $variables['output'] = [ + '#type' => 'html_tag', + '#tag' => 'span', + '#value' => $link->getText(), + '#attributes' => [ + "class" => array( + $entity->getEntityTypeId(), + $entity->getEntityTypeId().'-'.$entity->bundle(), + $entity->getEntityTypeId().'-'.$entity->bundle().'-'.$entity->id(), + ) + ] + ]; + }else{ - $attributes = array( - "class" => $new_classes + // build new classes + $new_classes = array( + $entity->getEntityTypeId(), + $entity->getEntityTypeId().'-'.$entity->bundle(), + $entity->getEntityTypeId().'-'.$entity->bundle().'-'.$entity->id(), ); + + // get the entity link and url + $link = $entity->toLink(); + $url = $entity->toLink()->getUrl(); + + // set the active_class option to the url + $url->setOption('set_active_class', true); + + // add new classes to the url (without overwriting existing once) + $options = $url->getOptions(); + if(isset($options['attributes']) && $attributes = $options['attributes']){ + if(isset($attributes['class']) && $classes = $attributes['class']){ + $attributes['class'] += $new_classes; + }else{ + $attributes['class'] = $new_classes; + } + }else{ + $attributes = array( + "class" => $new_classes + ); + } + $url->setOption('attributes', $attributes); + + // update the url of the link + $link->setUrl($url); + + // overwrite the output + $variables['output'] = $link->toRenderable(); + } - $url->setOption('attributes', $attributes); - - // update the url of the link - $link->setUrl($url); - - // overwrite the output - $variables['output'] = $link->toRenderable(); } } diff --git a/web/themes/custom/popsu/sass/pages/partials/_header_footer.scss b/web/themes/custom/popsu/sass/pages/partials/_header_footer.scss index 6d0b3b9a..cfb67198 100644 --- a/web/themes/custom/popsu/sass/pages/partials/_header_footer.scss +++ b/web/themes/custom/popsu/sass/pages/partials/_header_footer.scss @@ -180,7 +180,7 @@ text-align: center; display: inline-block; width: auto; - a{ + a, span{ text-transform: uppercase; text-decoration: none; font-weight: 600;