Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

Commit e894a9c

Browse files
author
Diego Lorenzo
committed
Ensures that the desired language is available.
When extracting field datat if a specific language is provided, then we need to make sure that if the data is not available in the language specified, then return NULL and exit out of the function otherwise we will get PHP warnings.
1 parent 79023b6 commit e894a9c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/modules/dosomething/dosomething_helpers/dosomething_helpers.module

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ function dosomething_helpers_extract_field_data($field, $language = LANGUAGE_NON
118118
}
119119
// ---
120120

121+
if (!array_key_exists($language, $field)) {
122+
return NULL;
123+
}
124+
121125
$data = $field[$language];
122126

123127
$values = array();

lib/themes/dosomething/paraneue_dosomething/includes/preprocess.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,18 @@ function paraneue_dosomething_preprocess_page(&$vars) {
150150
$header_vars = array(
151151
'title' => drupal_get_title(),
152152
);
153+
153154
// If there's a subtitle field on this node, send it to the header
154155
global $user;
156+
155157
if ($user->uid) {
156158
$language = $user->language;
157159
}
158160
else {
159161
$code = dosomething_global_get_current_country_code();
160162
$language = dosomething_global_convert_country_to_language($code);
161163
}
164+
162165
$field_data = dosomething_helpers_extract_field_data($vars['node']->field_subtitle, $language);
163166
if (isset($field_data)) {
164167
$header_vars['subtitle'] = $field_data;

0 commit comments

Comments
 (0)