Skip to content

Commit

Permalink
Close #2924 Add suffix field to person.
Browse files Browse the repository at this point in the history
  • Loading branch information
trackleft committed Sep 23, 2024
1 parent a2ce0e9 commit a964c32
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
langcode: en
status: true
dependencies:
module:
- node
id: node.field_az_suffix
field_name: field_az_suffix
entity_type: node
type: string
settings:
max_length: 255
case_sensitive: false
is_ascii: false
module: core
locked: false
cardinality: -1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
13 changes: 13 additions & 0 deletions modules/custom/az_demo/data/az_demo_person_node.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"id":1,
"az_lname" : "And",
"az_fname" : "Anders",
"az_suffix" : "M.A.",
"az_email" : "[email protected]",
"az_bio" : "<p>Enjoyed a lengthy Hollywood career before his current employment at the University of Arizona (joint with the University of Oregon).</p>",
"az_phones" : "031-667-1071|053-246-1514",
Expand All @@ -24,6 +25,7 @@
"id":2,
"az_lname" : "Ælling",
"az_fname" : "Grimme",
"az_suffix" : "M.S.",
"az_email" : "[email protected]",
"az_bio" : "<p>A leading expert on both developmental psychology and characters in the novels of Marcel Proust.</p>",
"az_phones" : "071-388-2333",
Expand All @@ -44,6 +46,7 @@
"id":3,
"az_lname" : "An'ersen",
"az_fname" : "José",
"az_suffix" : "M.A.|Ph.D.",
"az_email" : "[email protected]",
"az_bio" : "<p>His life's work has been to contradict everything that Kierkegaard stood for.</p>",
"az_phones" : "071-831-6181",
Expand All @@ -64,6 +67,7 @@
"id":4,
"az_lname" : "Quack",
"az_fname" : "Albertina",
"az_suffix" : "M.A.|Ph.D.",
"az_email" : "[email protected]",
"az_bio" : "<p>Dr. Quack is a leading expert on the Cult of the Sacred Duck, a highly significant influence on Urnfield and Hallstatt iconography in Central Europe, but now unfortunately lapsed into obscurity.</p>",
"az_phones" : "086-572-2311",
Expand All @@ -84,6 +88,7 @@
"id":5,
"az_lname" : "Nasier",
"az_fname" : "Alcofribas",
"az_suffix" : "Ph.D.",
"az_email" : "[email protected]",
"az_bio" : "<p>A central figure in the study of late fifteenth to early sixteenth century French literature.</p>",
"az_phones" : "091-374-2832",
Expand All @@ -108,6 +113,7 @@
"id":6,
"az_lname" : "Urquhart",
"az_fname" : "Thomas",
"az_suffix" : "Ph.D.",
"az_email" : "[email protected]",
"az_bio" : "<p>Author of <em>Trissotetras</em>, a radically different approach to trigonometric notation.</p>",
"az_phones" : "041-334-8100",
Expand All @@ -128,6 +134,7 @@
"id":7,
"az_lname" : "Horne",
"az_fname" : "Janet",
"az_suffix" : "M.S.",
"az_email" : "[email protected]",
"az_bio" : "<p>Currently investigating the use of herbal supplements as an alternative to nutrition.</p>",
"az_phones" : "041-552-8467",
Expand All @@ -148,6 +155,7 @@
"id":8,
"az_lname" : "de Espinosa",
"az_fname" : "Antonio",
"az_suffix" : "M.S.",
"az_email" : "[email protected]",
"az_bio" : "<p>A leading proponent of high-quality book production in the New World.</p>",
"az_phones" : "023-475-2795|021-471-2611",
Expand All @@ -168,6 +176,7 @@
"id":9,
"az_lname" : "Strozzi",
"az_fname" : "Barbara",
"az_suffix" : "M.M.",
"az_email" : "[email protected]",
"az_bio" : "<p>Known for a productive and distinguished career in composition, as well as vocal performance.</p>",
"az_phones" : "081-981-7331",
Expand All @@ -188,6 +197,7 @@
"id":10,
"az_lname" : "Muse",
"az_fname" : "Urania",
"az_suffix" : "Ph.D.",
"az_email" : "[email protected]",
"az_bio" : "<p>The inspiration for generations of astronomers.</p>",
"az_phones" : "022-333-8848",
Expand All @@ -208,6 +218,7 @@
"id":11,
"az_lname" : "Giovanni",
"az_fname" : "Donald",
"az_suffix" : "Ph.D.",
"az_email" : "[email protected]",
"az_bio" : "<p>At final count, his regionally localized accomplishments stood at at least 1003.</p>",
"az_phones" : "086-572-2311",
Expand All @@ -228,6 +239,7 @@
"id":12,
"az_lname" : "Wildcat",
"az_fname" : "Wilbur",
"az_suffix" : "M.S.",
"az_email" : "[email protected]",
"az_bio" : "<p>On April 17, 1916, the UA's live mascot Rufus Wildcat (named after then UA President Rufus Bernard Von KleinSmidt) met with an untimely death. Decades later, after being without a mascot, UA students Richard Heller, '65, and John Paquette, '61 developed the idea for a costumed human mascot. On November 7, 1959, Wilbur the Wildcat was \"born,\" making his debut at the UA vs. Texas Tech football game. The new mascot, portrayed by Ed Stuckenoff, `64, was an immediate hit</p><p> The original costume was head-to-toe fur with an American flag patch on the left shoulder. It was cartoon-style with big round eyes, a button nose, and a curved black line for a mouth. A few years later, in an attempt to look more \"human\", an upgraded version of Wilbur eliminated the fur body and replaced it with an Arizona sweater and pair of slacks. This look lasted until the 1970's, during which Wilbur underwent a \"Rhinestone Cowboy\" phase. In this costume, Wilbur donned a vest and blue jeans, cowboy boots, a holster and gun, and an oversized paper-mache head. This look lasted until 1982, when Wilbur re-acquired his fur.</p><p>Since the early 1980's, Wilbur the Wildcat's character and image has undergone various style changes while maintaining a \"furry\" body. Today, Wilbur, along with his counterpart and wife, Wilma the Wildcat, and the Arizona Cheerleaders, is part of the Spirit Program within Arizona Athletics Department. Wilbur is not only present at all UA home football and men's basketball games, but he is also involved in many aspects of campus life. In addition to campus commitments, Wilbur and Wilma the Wildcat spend a great deal of time working with local community organizations and non-profit groups.</p><hr><h2 class=\"h3\">Wildcats Nickname</h2><p>The Wildcats got their name after a hard fought football game against the Occidental College Tigers on November 7, 1914. A Los Angeles Times columnist wrote that the Arizona team \"Showed the fight of Wildcats.\"</p><hr><h2 class=\"h3\">Wilbur Facts</h2><ul><li>The University of Arizona's original mascot was actually a live bobcat, purchased by the freshman football team from army blacksmith F.W. Fawkins, for $9.41. The team presented the bobcat, then called Tom Easter, as a gift to the student body, to whom he was first introduced at an assembly on October 18, 1915.</li><li>Shortly there after he was officially named Rufus Arizona, after then UA President Rufus Bernard Von KleinSmid.</li><li>Rufus Arizona had an untimely death on April 17, 1916. As reported by the Arizona Wildcat, \"while endeavoring to perform gymnastics stunts in the limbs of a tree to which he was tied, Rufus Arizona ... fell and was hung.\" The original Rufus passed on, but successors followed. (Live mascots were used off and on between the early 1900's and the late 1950's.)</li><li>Decades later, UA students Richard Heller, '62, and John Paquette, '60 presented the idea for a costumed human mascot. On November 7, 1959, Wilbur the Wildcat was \"born,\" making his first appearance at the UA vs. Texas Tech football game. He was an immediate hit.</li><li>The original costume was head-to-toe fur with an American flag patch on the left shoulder. This costume was very \"cartoony.\" It had big rounded eyes, a button nose and a curved black line for a mouth.</li><li>A few years later, in an attempt to take on a more humanistic look, an upgraded version of Wilbur eliminated the fur body and replaced it with an Arizona sweater and pair of slacks. This look lasted until the 1970's, during which Wilbur underwent a \"Rhinestone Cowboy\" phase. He had an oversized, paper mache head, and donned blue jeans, a vest, cowboy boots and a holster and gun.</li><li>This look lasted until 1982, when Wilbur re-acquired his fur. Since then, the concept of a mascot head and a furry body has been maintained through various style changes.</li><li>Today, Wilbur is part of the Spirit Program at the University of Arizona, which also includes Wilma the Wildcat and the Cheerleaders. As part of the Spirit Program, Wilbur is not only at virtually every UA home game, but he is also very involved in the Tucson community doing appearances and spending time with kids of all ages.</li><li>Wilbur's primary responsibilities are Football, and Men's Basketball.</li><li>With the exception of a small scholarship ($200) they do it all for the experience.</li><li>In, 2006, Wilbur and Wilma renewed their vow at the ASU to celebrate their 20th wedding anniversary.</li></ul>",
"az_phones" : "520-621-5555",
Expand All @@ -248,6 +260,7 @@
"id":13,
"az_lname" : "Wildcat",
"az_fname" : "Wilma",
"az_suffix" : "Ph.D.",
"az_email" : "[email protected]",
"az_bio" : "<p>At games, Wilma helps keep crowds and fans motivated with her enthusiasim and strong UA spirit. She attributes her success as a kind, loveable wildcat to the endurence, preperation, and devotion she possesses.</p><hr><h2 class=\"h3\">Wilma Facts</h2><ul><li>Wilma was created when costume designers were attempting to make another costume for Wilbur. They created Wilma instead.</li><li>Wilma the Wildcat made her first appearance on March 1, 1986. She was on a blind date with Wilbur.</li><li>Wilbur and Wilma were married on November 21, 1986 before the Arizona-Arizona State football game.</li><li>Wilma's primary responsibilities include Women's Volleyball and Women's Basketball.</li><li>With the exception of a small scholarship ($200) they do it all for the experience.</li><li>In, 2006, Wilbur and Wilma renewed their vowed at the ASU to celebrate their 20th wedding anniversary.</li></ul>",
"az_phones" : "520-621-5555",
Expand Down
8 changes: 8 additions & 0 deletions modules/custom/az_demo/migrations/az_demo_person_node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ source:
-
name: field_az_lname
selector: az_lname
-
name: field_az_suffix
selector: az_suffix
-
name: field_az_email
selector: az_email
Expand Down Expand Up @@ -64,6 +67,11 @@ process:

field_az_lname: field_az_lname

field_az_suffix:
plugin: explode
source: field_az_suffix
delimiter: '|'

field_az_email: field_az_email

field_az_titles:
Expand Down
50 changes: 50 additions & 0 deletions modules/custom/az_person/az_person.module
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*/

use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\node\Entity\NodeType;

/**
* Implements hook_preprocess_node().
Expand Down Expand Up @@ -44,3 +47,50 @@ function az_person_entity_bundle_field_info_alter(&$fields, EntityTypeInterface
$fields['field_az_netid']->addConstraint('UniqueField');
}
}

/**
* Implements hook_entity_extra_field_info().
*/
function az_person_entity_extra_field_info() {
$extra = [];

// Check to see if our content type exists.
$bundle = NodeType::load('az_person');
if ($bundle) {
// Comma pseudo field.
$extra['node'][$bundle->id()]['display']['az_person_suffix'] = [
'label' => t('Person name suffix with leading comma.'),
'description' => "This is a pseudo field from az_person.",
'weight' => 50,
'visible' => FALSE,
];
}

return $extra;
}

/**
* Implements hook_ENTITY_TYPE_view().
*/
function az_person_node_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
if ($entity instanceof \Drupal\Core\Entity\FieldableEntityInterface) {
if ($entity->hasField('field_az_suffix')) {
$suffix_field = $entity->get('field_az_suffix');
$items = [];
foreach ($suffix_field as $suffix_item) {
$items[] = [
'#markup' => $suffix_item->value,
'#wrapper_attributes' => ['class' => ['list-inline-item']],
];
}
$build['az_person_suffix'] = [
'#theme' => 'item_list',
'#items' => $items,
'#context' => ['list_style' => 'comma-list'],
'#attributes' => ['class' => ['list-inline']],
'#wrapper_attributes' => ['class' => ['inline','with-leading-comma']],
'#theme_wrappers' => [],
];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies:
- field.field.node.az_person.field_az_person_category_sec
- field.field.node.az_person.field_az_phones
- field.field.node.az_person.field_az_pronouns
- field.field.node.az_person.field_az_suffix
- field.field.node.az_person.field_az_titles
- node.type.az_person
module:
Expand Down Expand Up @@ -126,6 +127,7 @@ third_party_settings:
group_title_link:
children:
- smart_title
- az_person_suffix
label: 'Title Link'
parent_name: group_title_heading
region: content
Expand All @@ -149,12 +151,17 @@ targetEntityType: node
bundle: az_person
mode: az_card
content:
az_person_suffix:
settings: { }
third_party_settings: { }
weight: 10
region: content
field_az_email:
type: email_mailto
label: hidden
settings: { }
third_party_settings: { }
weight: 7
weight: 8
region: content
field_az_media_image:
type: entity_reference_entity_view
Expand All @@ -179,7 +186,7 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 8
weight: 9
region: content
field_az_titles:
type: string
Expand All @@ -206,4 +213,5 @@ hidden:
field_az_netid: true
field_az_person_category: true
field_az_person_category_sec: true
field_az_suffix: true
links: true
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies:
- field.field.node.az_person.field_az_person_category_sec
- field.field.node.az_person.field_az_phones
- field.field.node.az_person.field_az_pronouns
- field.field.node.az_person.field_az_suffix
- field.field.node.az_person.field_az_titles
- image.style.az_medium
- node.type.az_person
Expand Down Expand Up @@ -113,6 +114,7 @@ third_party_settings:
group_title_link:
children:
- smart_title
- az_person_suffix
label: 'Title Link'
parent_name: group_title_heading
region: content
Expand Down Expand Up @@ -170,12 +172,17 @@ targetEntityType: node
bundle: az_person
mode: az_row
content:
az_person_suffix:
settings: { }
third_party_settings: { }
weight: 6
region: content
field_az_email:
type: email_mailto
label: hidden
settings: { }
third_party_settings: { }
weight: 6
weight: 7
region: content
field_az_media_image:
type: media_thumbnail
Expand All @@ -202,15 +209,15 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 7
weight: 8
region: content
field_az_titles:
type: string
label: hidden
settings:
link_to_entity: false
third_party_settings: { }
weight: 22
weight: 21
region: content
smart_title:
settings: { }
Expand All @@ -229,4 +236,5 @@ hidden:
field_az_netid: true
field_az_person_category: true
field_az_person_category_sec: true
field_az_suffix: true
links: true
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ dependencies:
- field.field.node.az_person.field_az_links
- field.field.node.az_person.field_az_lname
- field.field.node.az_person.field_az_media_image
- field.field.node.az_person.field_az_metatag
- field.field.node.az_person.field_az_netid
- field.field.node.az_person.field_az_person_category
- field.field.node.az_person.field_az_person_category_sec
- field.field.node.az_person.field_az_phones
- field.field.node.az_person.field_az_pronouns
- field.field.node.az_person.field_az_suffix
- field.field.node.az_person.field_az_titles
- node.type.az_person
module:
Expand Down Expand Up @@ -121,6 +123,7 @@ third_party_settings:
group_column_text:
children:
- smart_title
- az_person_suffix
- group_job_titles
- group_view_person
label: 'Column - Text'
Expand All @@ -145,7 +148,7 @@ third_party_settings:
label: 'Job Title(s)'
parent_name: group_column_text
region: content
weight: 9
weight: 10
format_type: html_element
format_settings:
classes: 'text-muted font-weight-normal'
Expand All @@ -163,7 +166,7 @@ third_party_settings:
label: 'View profile'
parent_name: group_column_text
region: content
weight: 10
weight: 11
format_type: html_element
format_settings:
classes: 'card-clickable-link mt-2 pb-3'
Expand Down Expand Up @@ -193,6 +196,11 @@ targetEntityType: node
bundle: az_person
mode: az_row_with_background
content:
az_person_suffix:
settings: { }
third_party_settings: { }
weight: 9
region: content
field_az_media_image:
type: entity_reference_entity_view
label: hidden
Expand All @@ -208,7 +216,7 @@ content:
settings:
link_to_entity: false
third_party_settings: { }
weight: 10
weight: 3
region: content
smart_title:
settings: { }
Expand All @@ -225,9 +233,11 @@ hidden:
field_az_link: true
field_az_links: true
field_az_lname: true
field_az_metatag: true
field_az_netid: true
field_az_person_category: true
field_az_person_category_sec: true
field_az_phones: true
field_az_pronouns: true
field_az_suffix: true
links: true
Loading

0 comments on commit a964c32

Please sign in to comment.