Skip to content
Snippets Groups Projects
Commit bd1ce547 authored by Konstantinos Platis's avatar Konstantinos Platis
Browse files

Fixed issue of event full content pattern not displaying link in

event_type
parent cd7f9d2c
No related branches found
No related tags found
2 merge requests!47Merge RC v2.6.0 to master,!38Resolve "Event full content pattern does not display link field in event page content type"
......@@ -110,16 +110,21 @@
{% if link | render %}
<div class="event-node-full-content-place">
{% if link | render %}
{% if cern_node_type != "event_page" %}
<div class="hard-text">
<p>
<a href="{{ link }}" target="_blank">{{ 'Go to Indico Event'|trans }}</a>
</p>
</div>
<div class="custom-text">
<p></p>
</div>
{% endif %}
<div class="hard-text">
{# If the link is a URL (not plain text)#}
{% if is_url(link) %}
<p>
<a href="{{ link | get_url_link }}" target="_blank">{{ 'Go to Indico Event'|trans }}</a>
</p>
{% else %}
<p>
<a href="{{ link }}" target="_blank">{{ 'Go to Indico Event'|trans }}</a>
</p>
{% endif %}
</div>
<div class="custom-text">
<p></p>
</div>
{% endif %}
</div>
{% endif %}
......@@ -136,7 +141,6 @@
<p>{{ 'Where: '|trans }}&nbsp;</p>
</div>
<div class="custom-text">
{% if map_room | render %}
<a href="{{ map_room }}"> {{ room }} </a> {% if room | render %} {% if place | render %} {{ 'at'|trans }} {% endif %} {% endif %} {{ place }}
{% else %}
......
......@@ -54,6 +54,8 @@ class CernComponentsTwigExtension extends \Twig_Extension {
*/
public function getFilters() {
return [
new \Twig_SimpleFilter('is_url', [$this,'isURL']),
new \Twig_SimpleFilter('get_url_link', [$this,'getUrlLink']),
new \Twig_SimpleFilter('addbasepath', [$this, 'addbasepath']),
new \Twig_SimpleFilter('htmlspecialchars', [$this, 'htmlSpecialChars']),
new \Twig_SimpleFilter('openlink', [$this, 'openLink']),
......@@ -77,7 +79,7 @@ class CernComponentsTwigExtension extends \Twig_Extension {
new \Twig_SimpleFilter('get_tag_attribute', [$this,'getTagAttribute']),
new \Twig_SimpleFilter('set_tag_attribute', [$this,'setTagAttribute']),
new \Twig_SimpleFilter('get_path', [$this,'getPath']),
];
];
}
/**
......@@ -85,6 +87,8 @@ class CernComponentsTwigExtension extends \Twig_Extension {
*/
public function getFunctions() {
return [
new \Twig_SimpleFunction('is_url', [$this,'isURL']),
new \Twig_SimpleFunction('get_url_link', [$this,'getUrlLink']),
new \Twig_SimpleFunction('get_current_language', [$this, 'getCurrentLanguage']),
new \Twig_SimpleFunction('addbasepath', [$this, 'addBasePath']),
new \Twig_SimpleFunction('htmlspecialchars', [$this, 'htmlSpecialChars']),
......@@ -109,10 +113,47 @@ class CernComponentsTwigExtension extends \Twig_Extension {
new \Twig_SimpleFunction('get_cds_info', [$this,'getCdsInfo']),
new \Twig_SimpleFunction('get_tag_attribute', [$this,'getTagAttribute']),
new \Twig_SimpleFunction('set_tag_attribute', [$this,'setTagAttribute']),
new \Twig_SimpleFilter('get_path', [$this,'getPath']),
];
];
}
/**
* Checks if the given variable is a URL
*
* @param $variable
* @return bool
*/
public function isURL($variable) {
reset($variable);
$first_key = key($variable);
if (array_key_exists('#type', $variable[$first_key]['0']) && $variable[$first_key]['0']['#type'] == "link"){
return true;
}
else{
return false;
}
}
/**
* Returns the URL of a link. Developed because for pattern I don't know in advance the field name so I get the first
* one.
*
* @param $link
* @return string
*/
public function getUrlLink($link){
reset($link);
$first_key = key($link);
if ( array_key_exists('#url', $link[$first_key]['0'])){
return $link[$first_key]['0']['#url'];
}
else{
return '';
}
}
/**
* Returns the current language of the
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment