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

Merge branch...

Merge branch '28-event-full-content-pattern-does-not-display-link-field-in-event-page-content-type' into 'dev'

Resolve "Event full content pattern does not display link field in event page content type"

See merge request !38
parents cd7f9d2c bd1ce547
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 @@ ...@@ -110,16 +110,21 @@
{% if link | render %} {% if link | render %}
<div class="event-node-full-content-place"> <div class="event-node-full-content-place">
{% if link | render %} {% if link | render %}
{% if cern_node_type != "event_page" %} <div class="hard-text">
<div class="hard-text"> {# If the link is a URL (not plain text)#}
<p> {% if is_url(link) %}
<a href="{{ link }}" target="_blank">{{ 'Go to Indico Event'|trans }}</a> <p>
</p> <a href="{{ link | get_url_link }}" target="_blank">{{ 'Go to Indico Event'|trans }}</a>
</div> </p>
<div class="custom-text"> {% else %}
<p></p> <p>
</div> <a href="{{ link }}" target="_blank">{{ 'Go to Indico Event'|trans }}</a>
{% endif %} </p>
{% endif %}
</div>
<div class="custom-text">
<p></p>
</div>
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
...@@ -136,7 +141,6 @@ ...@@ -136,7 +141,6 @@
<p>{{ 'Where: '|trans }}&nbsp;</p> <p>{{ 'Where: '|trans }}&nbsp;</p>
</div> </div>
<div class="custom-text"> <div class="custom-text">
{% if map_room | render %} {% if map_room | render %}
<a href="{{ map_room }}"> {{ room }} </a> {% if room | render %} {% if place | render %} {{ 'at'|trans }} {% endif %} {% endif %} {{ place }} <a href="{{ map_room }}"> {{ room }} </a> {% if room | render %} {% if place | render %} {{ 'at'|trans }} {% endif %} {% endif %} {{ place }}
{% else %} {% else %}
......
...@@ -54,6 +54,8 @@ class CernComponentsTwigExtension extends \Twig_Extension { ...@@ -54,6 +54,8 @@ class CernComponentsTwigExtension extends \Twig_Extension {
*/ */
public function getFilters() { public function getFilters() {
return [ 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('addbasepath', [$this, 'addbasepath']),
new \Twig_SimpleFilter('htmlspecialchars', [$this, 'htmlSpecialChars']), new \Twig_SimpleFilter('htmlspecialchars', [$this, 'htmlSpecialChars']),
new \Twig_SimpleFilter('openlink', [$this, 'openLink']), new \Twig_SimpleFilter('openlink', [$this, 'openLink']),
...@@ -77,7 +79,7 @@ class CernComponentsTwigExtension extends \Twig_Extension { ...@@ -77,7 +79,7 @@ class CernComponentsTwigExtension extends \Twig_Extension {
new \Twig_SimpleFilter('get_tag_attribute', [$this,'getTagAttribute']), new \Twig_SimpleFilter('get_tag_attribute', [$this,'getTagAttribute']),
new \Twig_SimpleFilter('set_tag_attribute', [$this,'setTagAttribute']), new \Twig_SimpleFilter('set_tag_attribute', [$this,'setTagAttribute']),
new \Twig_SimpleFilter('get_path', [$this,'getPath']), new \Twig_SimpleFilter('get_path', [$this,'getPath']),
]; ];
} }
/** /**
...@@ -85,6 +87,8 @@ class CernComponentsTwigExtension extends \Twig_Extension { ...@@ -85,6 +87,8 @@ class CernComponentsTwigExtension extends \Twig_Extension {
*/ */
public function getFunctions() { public function getFunctions() {
return [ 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('get_current_language', [$this, 'getCurrentLanguage']),
new \Twig_SimpleFunction('addbasepath', [$this, 'addBasePath']), new \Twig_SimpleFunction('addbasepath', [$this, 'addBasePath']),
new \Twig_SimpleFunction('htmlspecialchars', [$this, 'htmlSpecialChars']), new \Twig_SimpleFunction('htmlspecialchars', [$this, 'htmlSpecialChars']),
...@@ -109,10 +113,47 @@ class CernComponentsTwigExtension extends \Twig_Extension { ...@@ -109,10 +113,47 @@ class CernComponentsTwigExtension extends \Twig_Extension {
new \Twig_SimpleFunction('get_cds_info', [$this,'getCdsInfo']), new \Twig_SimpleFunction('get_cds_info', [$this,'getCdsInfo']),
new \Twig_SimpleFunction('get_tag_attribute', [$this,'getTagAttribute']), new \Twig_SimpleFunction('get_tag_attribute', [$this,'getTagAttribute']),
new \Twig_SimpleFunction('set_tag_attribute', [$this,'setTagAttribute']), 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 * Returns the current language of the
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment