deactivated popsu_monde links, sass needs to be compiled
This commit is contained in:
		@@ -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();
 | 
			
		||||
  } 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -180,7 +180,7 @@
 | 
			
		||||
		text-align: center;
 | 
			
		||||
		display: inline-block;
 | 
			
		||||
		width: auto;
 | 
			
		||||
        a{
 | 
			
		||||
        a, span{
 | 
			
		||||
            text-transform: uppercase;
 | 
			
		||||
            text-decoration: none;
 | 
			
		||||
            font-weight: 600;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user