File tree 3 files changed +21
-11
lines changed
html/themes/custom/iasc_common_design
3 files changed +21
-11
lines changed Original file line number Diff line number Diff line change 6
6
*/
7
7
8
8
use Drupal\Core\Form\FormStateInterface;
9
+ use Drupal\media\Entity\Media;
9
10
10
11
/**
11
12
* Implements template_preprocess_field().
@@ -125,6 +126,17 @@ function iasc_common_design_preprocess_node(&$variables) {
125
126
$variables['event_time']['output'] = $variables['event_time']['start'] . ' — ' . $variables['event_time']['end'] . ' (' . $variables['event_time']['timezone'] . ')';
126
127
}
127
128
}
129
+
130
+ $bundle = $node->bundle();
131
+
132
+ if ($bundle == 'oa_wiki_page' && ($variables['elements']['#view_mode'] == 'teaser' || $variables['elements']['#view_mode'] == 'title')) {
133
+ $document_file = $node->get('field_media_files')->getValue();
134
+
135
+ if (!empty($document_file)) {
136
+ $entity = Media::load($document_file[0]['target_id']);
137
+ $variables['document_file'] = $entity->field_media_file->entity->createFileUrl();
138
+ }
139
+ }
128
140
}
129
141
130
142
/**
Original file line number Diff line number Diff line change 83
83
%}
84
84
{{ attach_library(' common_design/cd-teaser' ) }}
85
85
86
- {% set fileUrl = node .field_media_files .0.entity .uri .value ? file_url(node .field_media_files .0.entity .uri .value ) : url %}
87
86
{% set showPage = node .field_oa_wiki_page_no_redirect .0.value %}
88
87
89
88
<article {{ attributes.addClass (classes ) }}>
101
100
{% if showPage %}
102
101
<a href =" {{ url }}" rel =" bookmark" >{{ label }}</a >
103
102
{% else %}
104
- <a href =" {{ fileUrl }}" title =" Download" >{{ label }}</a >
103
+ <a href =" {{ document_file }}" title =" Download" >{{ label }}</a >
105
104
{% endif %}
106
105
</h3 >
107
106
{% endif %}
Original file line number Diff line number Diff line change 72
72
#}
73
73
{%
74
74
set classes = [
75
- ' node' ,
76
- ' node--type-' ~ node .bundle |clean_class,
77
- node.isPromoted () ? ' node--promoted' ,
78
- node.isSticky () ? ' node--sticky' ,
79
- not node.isPublished () ? ' node--unpublished' ,
80
- view_mode ? ' node--view-mode-' ~ view_mode |clean_class
81
- ]
75
+ ' node' ,
76
+ ' node--type-' ~ node .bundle |clean_class,
77
+ node.isPromoted () ? ' node--promoted' ,
78
+ node.isSticky () ? ' node--sticky' ,
79
+ not node.isPublished () ? ' node--unpublished' ,
80
+ view_mode ? ' node--view-mode-' ~ view_mode |clean_class
81
+ ]
82
82
%}
83
83
{{ attach_library(' common_design/cd-bullet-list' ) }}
84
84
85
- {% set fileUrl = node .field_media_files .0.entity .uri .value ? file_url(node .field_media_files .0.entity .uri .value ) : url %}
86
85
{% set showPage = node .field_oa_wiki_page_no_redirect .0.value %}
87
86
88
87
<article {{ attributes.addClass (classes ) }}>
91
90
{% if showPage %}
92
91
<a href =" {{ url }}" rel =" bookmark" >
93
92
{% else %}
94
- <a href =" {{ fileUrl }}" title =" Download" >
93
+ <a href =" {{ document_file }}" title =" Download" >
95
94
{% endif %}
96
95
{{ label }}
97
96
</a >
You can’t perform that action at this time.
0 commit comments