Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CERN Components
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Web Team
Drupal
Public Drupal Repositories
Drupal 8
D8 Modules
CERN Components
Commits
bd1ce547
Commit
bd1ce547
authored
5 years ago
by
Konstantinos Platis
Browse files
Options
Downloads
Patches
Plain Diff
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
!47
Merge RC v2.6.0 to master
,
!38
Resolve "Event full content pattern does not display link field in event page content type"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
patterns/molecules/event-display/event-display.html.twig
+15
-11
15 additions, 11 deletions
patterns/molecules/event-display/event-display.html.twig
src/TwigExtension/CernComponentsTwigExtension.php
+44
-3
44 additions, 3 deletions
src/TwigExtension/CernComponentsTwigExtension.php
with
59 additions
and
14 deletions
patterns/molecules/event-display/event-display.html.twig
+
15
−
11
View file @
bd1ce547
...
@@ -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
}}
</p>
<p>
{{
'Where: '
|
trans
}}
</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
%}
...
...
This diff is collapsed.
Click to expand it.
src/TwigExtension/CernComponentsTwigExtension.php
+
44
−
3
View file @
bd1ce547
...
@@ -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
*
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment