header et menu v0

This commit is contained in:
armansansd
2021-06-24 16:04:02 +02:00
parent c87d8dbf9b
commit e1c693f94c
10 changed files with 303 additions and 164 deletions

View File

@@ -53,49 +53,58 @@ function popsu_preprocess_region(&$variables) {
}
// function popsu_theme_suggestions_views_view_alter(array &$suggestions, array $variables) {
// $v = $variables;
// $suggestions[] = 'views_view__headerView';
// }
/**
* Implements hook_preprocess_block().
*/
// function popsu_preprocess_block(&$variables) {
// $t="t";
// }
function popsu_preprocess_views_view_field(&$variables){
// check if link to entoty option is true
$settings = $variables['field']->options['settings'];
if ($settings['link_to_entity']) {
// get the entity and build the classes
$entity = $variables['row']->_entity;
// build new classes
$new_classes = array(
$entity->getEntityTypeId(),
$entity->getEntityTypeId().'-'.$entity->bundle(),
$entity->getEntityTypeId().'-'.$entity->bundle().'-'.$entity->id()
);
// function popsu_preprocess_views_view_field(&$variables){
// // check if link to entoty option is true
// $settings = $variables['field']->options['settings'];
// if ($settings['link_to_entity']) {
// // get the entity and build the classes
// $entity = $variables['row']->_entity;
// // 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();
// // 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);
// // 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);
// // 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);
// // update the url of the link
// $link->setUrl($url);
// overwrite the output
$variables['output'] = $link->toRenderable();
}
}
// // overwrite the output
// $variables['output'] = $link->toRenderable();
// }
// }