deactivated popsu_monde links, sass needs to be compiled

This commit is contained in:
Bachir Soussi Chiadmi 2021-08-26 21:58:14 +02:00
parent 3c1a1914bd
commit 38bcce6c82
2 changed files with 62 additions and 36 deletions

View File

@ -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,12 +134,37 @@ 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();
// // $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{
// build new classes
$new_classes = array(
$entity->getEntityTypeId(),
@ -146,8 +172,6 @@ function popsu_preprocess_views_view_field(&$variables){
$entity->getEntityTypeId().'-'.$entity->bundle().'-'.$entity->id(),
);
// get the entity link and url
$link = $entity->toLink();
$url = $entity->toLink()->getUrl();
@ -175,6 +199,8 @@ function popsu_preprocess_views_view_field(&$variables){
// overwrite the output
$variables['output'] = $link->toRenderable();
}
}
}

View File

@ -180,7 +180,7 @@
text-align: center;
display: inline-block;
width: auto;
a{
a, span{
text-transform: uppercase;
text-decoration: none;
font-weight: 600;