Skip to content

Commit 82ee9f0

Browse files
authored
Merge pull request #52 from ASUWebPlatforms/ws2-1221
WS2-1221 - Added Why Choose ASU fields (and backend processing) to De…
2 parents 10a510f + 09f2ad7 commit 82ee9f0

File tree

3 files changed

+200
-53
lines changed

3 files changed

+200
-53
lines changed

config/install/core.entity_form_display.node.degree_detail_page.default.yml

Lines changed: 98 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ dependencies:
2626
- field.field.node.degree_detail_page.field_deg_dtl_intro_hide_market
2727
- field.field.node.degree_detail_page.field_deg_dtl_intro_hide_pgmdesc
2828
- field.field.node.degree_detail_page.field_deg_dtl_intro_hide_req_crs
29+
- field.field.node.degree_detail_page.field_deg_dtl_why_choose_1
30+
- field.field.node.degree_detail_page.field_deg_dtl_why_choose_2
31+
- field.field.node.degree_detail_page.field_deg_dtl_why_choose_intro
2932
- field.field.node.degree_detail_page.field_degree_detail_acadplancode
3033
- field.field.node.degree_detail_page.field_degree_detail_breadcrumbs
3134
- field.field.node.degree_detail_page.field_degree_detail_email_link
@@ -96,7 +99,7 @@ third_party_settings:
9699
label: 'Program contact info'
97100
region: content
98101
parent_name: ''
99-
weight: 13
102+
weight: 14
100103
format_type: fieldset
101104
format_settings:
102105
classes: ''
@@ -136,13 +139,53 @@ third_party_settings:
136139
label: 'Anchor menu'
137140
region: content
138141
parent_name: ''
139-
weight: 15
142+
weight: 16
140143
format_type: fieldset
141144
format_settings:
142145
classes: ''
143146
id: ''
144147
description: ''
145148
required_fields: true
149+
group_hide_degree_fields:
150+
children:
151+
- field_deg_dtl_intro_hide_market
152+
- field_deg_dtl_intro_hide_pgmdesc
153+
- field_deg_dtl_intro_hide_req_crs
154+
- field_deg_dtl_hide_app_reqs
155+
- field_deg_dtl_hide_chg_major
156+
- field_deg_dtl_hide_affording
157+
- field_deg_dtl_hide_flex_options
158+
- field_deg_dtl_hide_example_crs
159+
- field_deg_dtl_hide_global_opp
160+
- field_deg_dtl_hide_why_choos_asu
161+
- field_deg_dtl_hide_attend_online
162+
label: 'Hide Degree Fields'
163+
region: content
164+
parent_name: ''
165+
weight: 17
166+
format_type: fieldset
167+
format_settings:
168+
classes: hide-degree-fields
169+
show_empty_fields: true
170+
id: ''
171+
description: 'Select fields to not display on individual degree detail pages.'
172+
required_fields: true
173+
group_degrees_why_choose_asu:
174+
children:
175+
- field_deg_dtl_why_choose_intro
176+
- field_deg_dtl_why_choose_1
177+
- field_deg_dtl_why_choose_2
178+
label: 'Why Choose ASU'
179+
region: content
180+
parent_name: ''
181+
weight: 12
182+
format_type: fieldset
183+
format_settings:
184+
classes: ''
185+
show_empty_fields: true
186+
id: ''
187+
description: 'The following fields allow content creators to override the default "Why Choose ASU?" content as contained in the ASU Web standards Degree Detail pages.'
188+
required_fields: true
146189
id: node.degree_detail_page.default
147190
targetEntityType: node
148191
bundle: degree_detail_page
@@ -156,7 +199,7 @@ content:
156199
third_party_settings: { }
157200
field_deg_dtl_anchor_addl_anchor:
158201
type: link_default
159-
weight: 29
202+
weight: 28
160203
region: content
161204
settings:
162205
placeholder_url: ''
@@ -185,14 +228,14 @@ content:
185228
third_party_settings: { }
186229
field_deg_dtl_anchor_customize:
187230
type: boolean_checkbox
188-
weight: 25
231+
weight: 24
189232
region: content
190233
settings:
191234
display_label: true
192235
third_party_settings: { }
193236
field_deg_dtl_anchor_example_crs:
194237
type: boolean_checkbox
195-
weight: 24
238+
weight: 23
196239
region: content
197240
settings:
198241
display_label: true
@@ -206,7 +249,7 @@ content:
206249
third_party_settings: { }
207250
field_deg_dtl_anchor_global_opp:
208251
type: boolean_checkbox
209-
weight: 26
252+
weight: 25
210253
region: content
211254
settings:
212255
display_label: true
@@ -220,109 +263,141 @@ content:
220263
third_party_settings: { }
221264
field_deg_dtl_anchor_online:
222265
type: boolean_checkbox
223-
weight: 27
266+
weight: 26
224267
region: content
225268
settings:
226269
display_label: true
227270
third_party_settings: { }
228271
field_deg_dtl_anchor_outlook:
229272
type: boolean_checkbox
230-
weight: 23
273+
weight: 22
231274
region: content
232275
settings:
233276
display_label: true
234277
third_party_settings: { }
235278
field_deg_dtl_anchor_pgm_contact:
236279
type: boolean_checkbox
237-
weight: 28
280+
weight: 27
238281
region: content
239282
settings:
240283
display_label: true
241284
third_party_settings: { }
242285
field_deg_dtl_attend_online_img:
243286
type: media_library_widget
244-
weight: 12
287+
weight: 13
245288
region: content
246289
settings:
247290
media_types: { }
248291
third_party_settings: { }
249292
field_deg_dtl_hide_affording:
250293
type: boolean_checkbox
251-
weight: 21
294+
weight: 23
252295
region: content
253296
settings:
254297
display_label: true
255298
third_party_settings: { }
256299
field_deg_dtl_hide_app_reqs:
257300
type: boolean_checkbox
258-
weight: 19
301+
weight: 21
259302
region: content
260303
settings:
261304
display_label: true
262305
third_party_settings: { }
263306
field_deg_dtl_hide_attend_online:
264307
type: boolean_checkbox
265-
weight: 26
308+
weight: 28
266309
region: content
267310
settings:
268311
display_label: true
269312
third_party_settings: { }
270313
field_deg_dtl_hide_chg_major:
271314
type: boolean_checkbox
272-
weight: 20
315+
weight: 22
273316
region: content
274317
settings:
275318
display_label: true
276319
third_party_settings: { }
277320
field_deg_dtl_hide_example_crs:
278321
type: boolean_checkbox
279-
weight: 23
322+
weight: 25
280323
region: content
281324
settings:
282325
display_label: true
283326
third_party_settings: { }
284327
field_deg_dtl_hide_flex_options:
285328
type: boolean_checkbox
286-
weight: 22
329+
weight: 24
287330
region: content
288331
settings:
289332
display_label: true
290333
third_party_settings: { }
291334
field_deg_dtl_hide_global_opp:
292335
type: boolean_checkbox
293-
weight: 24
336+
weight: 26
294337
region: content
295338
settings:
296339
display_label: true
297340
third_party_settings: { }
298341
field_deg_dtl_hide_why_choos_asu:
299342
type: boolean_checkbox
300-
weight: 25
343+
weight: 27
301344
region: content
302345
settings:
303346
display_label: true
304347
third_party_settings: { }
305348
field_deg_dtl_intro_hide_market:
306349
type: boolean_checkbox
307-
weight: 16
350+
weight: 18
308351
region: content
309352
settings:
310353
display_label: true
311354
third_party_settings: { }
312355
field_deg_dtl_intro_hide_pgmdesc:
313356
type: boolean_checkbox
314-
weight: 17
357+
weight: 19
315358
region: content
316359
settings:
317360
display_label: true
318361
third_party_settings: { }
319362
field_deg_dtl_intro_hide_req_crs:
320363
type: boolean_checkbox
321-
weight: 18
364+
weight: 20
322365
region: content
323366
settings:
324367
display_label: true
325368
third_party_settings: { }
369+
field_deg_dtl_why_choose_1:
370+
type: entity_reference_paragraphs
371+
weight: 1
372+
region: content
373+
settings:
374+
title: Paragraph
375+
title_plural: Paragraphs
376+
edit_mode: open
377+
add_mode: dropdown
378+
form_display_mode: default
379+
default_paragraph_type: ''
380+
third_party_settings: { }
381+
field_deg_dtl_why_choose_2:
382+
type: entity_reference_paragraphs
383+
weight: 2
384+
region: content
385+
settings:
386+
title: Paragraph
387+
title_plural: Paragraphs
388+
edit_mode: open
389+
add_mode: dropdown
390+
form_display_mode: default
391+
default_paragraph_type: ''
392+
third_party_settings: { }
393+
field_deg_dtl_why_choose_intro:
394+
type: text_textarea
395+
weight: 0
396+
region: content
397+
settings:
398+
rows: 5
399+
placeholder: ''
400+
third_party_settings: { }
326401
field_degree_detail_acadplancode:
327402
type: string_textfield
328403
weight: 6
@@ -414,7 +489,7 @@ content:
414489
third_party_settings: { }
415490
field_degree_detail_nxtsteps:
416491
type: entity_reference_paragraphs
417-
weight: 14
492+
weight: 15
418493
region: content
419494
settings:
420495
title: Paragraph
@@ -503,7 +578,7 @@ content:
503578
placeholder: ''
504579
third_party_settings: { }
505580
url_redirects:
506-
weight: 27
581+
weight: 19
507582
region: content
508583
settings: { }
509584
third_party_settings: { }

src/AsuDegreeRfiHelperFunctions.php

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,55 @@ public function getRemoteVideoFieldValue($field) {
3838
return $video;
3939
}
4040

41-
public function getNxtStepsContent($paragraph) {
41+
public function getParagraphsContent($paragraph, $field = "nextSteps") {
4242
if (empty($paragraph)) {
4343
return;
4444
}
4545
$card = new \stdClass();
4646

47-
if (isset($paragraph->field_degree_nxtsteps_card_icon) && $paragraph->field_degree_nxtsteps_card_icon->icon_name) {
48-
$icon_name = $paragraph->field_degree_nxtsteps_card_icon->icon_name;
49-
$icon_style = $paragraph->field_degree_nxtsteps_card_icon->style;
50-
$card->icon = [$icon_style, $icon_name];
51-
}
47+
// shared fields
5248
if ($paragraph->field_degree_nxtsteps_card_title->value) {
5349
$card->title = $paragraph->field_degree_nxtsteps_card_title->value;
5450
}
51+
// Partially shared fields
52+
switch ($field) {
53+
case "whyChooseAsu":
54+
// whyChooseAsu - top image
55+
$image = new \stdClass();
56+
if (isset($paragraph->field_deg_dtl_why_card_image->target_id)) {
57+
$wca_image = $paragraph->field_deg_dtl_why_card_image->entity;
58+
$imageUri = $wca_image->getFileUri();
59+
$image->url = \Drupal::service('file_url_generator')->generateAbsoluteString($imageUri);
60+
$image->altText = $paragraph->field_deg_dtl_why_card_image->alt;
61+
$card->image = $image;
62+
}
63+
// Varying props names?
64+
$content = "text";
65+
$button = "button";
66+
break;
67+
default:
68+
$content = "content";
69+
$button = "buttonLink";
70+
// nextSteps - top icon
71+
if (isset($paragraph->field_degree_nxtsteps_card_icon) && $paragraph->field_degree_nxtsteps_card_icon->icon_name) {
72+
$icon_name = $paragraph->field_degree_nxtsteps_card_icon->icon_name;
73+
$icon_style = $paragraph->field_degree_nxtsteps_card_icon->style;
74+
$card->icon = [$icon_style, $icon_name];
75+
}
76+
break;
77+
}
5578
if ($paragraph->field_degree_nxtstep_card_contnt->value) {
56-
$card->content = $paragraph->field_degree_nxtstep_card_contnt->value;
79+
$card->{$content} = $paragraph->field_degree_nxtstep_card_contnt->value;
5780
}
5881
$buttonLink = new \stdClass();
5982
if ($paragraph->field_degree_nxtsteps_card_btn && $paragraph->field_degree_nxtsteps_card_btn->title && $paragraph->field_degree_nxtsteps_card_btn->uri) {
6083
$buttonLink->label = $paragraph->field_degree_nxtsteps_card_btn->title;
6184
$link = Url::fromUri($paragraph->field_degree_nxtsteps_card_btn->uri);
6285
$buttonLink->href = $link->toString();
63-
if ($paragraph->field_degree_nxtsteps_btn_color->value) {
64-
$buttonLink->color = $paragraph->field_degree_nxtsteps_btn_color->value;
65-
}
86+
$buttonLink->color = ($paragraph->field_degree_nxtsteps_btn_color->value) ?? "maroon";
6687
}
67-
6888
if (!empty((array)$buttonLink)) {
69-
$card->buttonLink = $buttonLink;
89+
$card->{$button} = $buttonLink;
7090
}
7191
return $card;
7292
}

0 commit comments

Comments
 (0)