From b1013328186efe1d6499f1eebc1c6bf11f328494 Mon Sep 17 00:00:00 2001 From: Stefan Freudenberg Date: Mon, 21 Nov 2016 11:48:36 +0100 Subject: [PATCH 1/5] Render author using a view mode specific template --- ...ty_view_mode.user.facebook_instant_articles_rss.yml | 10 ++++++++++ .../user--facebook-instant-articles-rss.html.twig | 1 + .../modules/thunder_fia/thunder_fia.module | 7 ++----- 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 modules/thunder_article/modules/thunder_fia/config/install/core.entity_view_mode.user.facebook_instant_articles_rss.yml create mode 100644 modules/thunder_article/modules/thunder_fia/templates/user--facebook-instant-articles-rss.html.twig diff --git a/modules/thunder_article/modules/thunder_fia/config/install/core.entity_view_mode.user.facebook_instant_articles_rss.yml b/modules/thunder_article/modules/thunder_fia/config/install/core.entity_view_mode.user.facebook_instant_articles_rss.yml new file mode 100644 index 000000000..2b43096a4 --- /dev/null +++ b/modules/thunder_article/modules/thunder_fia/config/install/core.entity_view_mode.user.facebook_instant_articles_rss.yml @@ -0,0 +1,10 @@ +uuid: 8ea3ec58-7ad0-4075-8e81-af849c980a3c +langcode: de +status: true +dependencies: + module: + - user +id: user.facebook_instant_articles_rss +label: 'Facebook Instant Articles: RSS' +targetEntityType: user +cache: true diff --git a/modules/thunder_article/modules/thunder_fia/templates/user--facebook-instant-articles-rss.html.twig b/modules/thunder_article/modules/thunder_fia/templates/user--facebook-instant-articles-rss.html.twig new file mode 100644 index 000000000..418bad732 --- /dev/null +++ b/modules/thunder_article/modules/thunder_fia/templates/user--facebook-instant-articles-rss.html.twig @@ -0,0 +1 @@ +{{ content.field_forename|render|trim }} {{ content.field_surname|render|trim }} diff --git a/modules/thunder_article/modules/thunder_fia/thunder_fia.module b/modules/thunder_article/modules/thunder_fia/thunder_fia.module index ce3fa9e7d..65f2d823d 100644 --- a/modules/thunder_article/modules/thunder_fia/thunder_fia.module +++ b/modules/thunder_article/modules/thunder_fia/thunder_fia.module @@ -58,11 +58,8 @@ function thunder_fia_preprocess_views_view_row_fia(&$variables) { } } - // Change author name to "firstname lastname". - $owner = $node->getOwner(); - $variables['options']['author'] = array( - '#markup' => '' . $owner->first_name->value . ' ' . $owner->last_name->value . '', - ); + $render_controller = \Drupal::entityTypeManager()->getViewBuilder($node->getOwner()->getEntityTypeId()); + $variables['options']['author'] = $render_controller->view($node->getOwner(), 'facebook_instant_articles_rss', NULL); } } From aa18ccbdbc7947fd15d126e6a1c9675df2ccb975 Mon Sep 17 00:00:00 2001 From: Stefan Freudenberg Date: Mon, 21 Nov 2016 14:54:45 +0100 Subject: [PATCH 2/5] Remove uuid from configuration and change its langcode to en --- ...ore.entity_view_mode.user.facebook_instant_articles_rss.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/thunder_article/modules/thunder_fia/config/install/core.entity_view_mode.user.facebook_instant_articles_rss.yml b/modules/thunder_article/modules/thunder_fia/config/install/core.entity_view_mode.user.facebook_instant_articles_rss.yml index 2b43096a4..33745e424 100644 --- a/modules/thunder_article/modules/thunder_fia/config/install/core.entity_view_mode.user.facebook_instant_articles_rss.yml +++ b/modules/thunder_article/modules/thunder_fia/config/install/core.entity_view_mode.user.facebook_instant_articles_rss.yml @@ -1,5 +1,4 @@ -uuid: 8ea3ec58-7ad0-4075-8e81-af849c980a3c -langcode: de +langcode: en status: true dependencies: module: From 68da16d273f523d14ccff9e3fe79fbd3912b12fa Mon Sep 17 00:00:00 2001 From: Stefan Freudenberg Date: Wed, 23 Nov 2016 11:03:01 +0100 Subject: [PATCH 3/5] Replace content of author tag with user's display name --- .../templates/user--facebook-instant-articles-rss.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/thunder_article/modules/thunder_fia/templates/user--facebook-instant-articles-rss.html.twig b/modules/thunder_article/modules/thunder_fia/templates/user--facebook-instant-articles-rss.html.twig index 418bad732..c3661be41 100644 --- a/modules/thunder_article/modules/thunder_fia/templates/user--facebook-instant-articles-rss.html.twig +++ b/modules/thunder_article/modules/thunder_fia/templates/user--facebook-instant-articles-rss.html.twig @@ -1 +1 @@ -{{ content.field_forename|render|trim }} {{ content.field_surname|render|trim }} +{{ user.displayName }} From e5fd324137fde65e7a400f232c268f485271224e Mon Sep 17 00:00:00 2001 From: Stefan Freudenberg Date: Wed, 8 Feb 2017 12:22:35 +0100 Subject: [PATCH 4/5] Implement update hook --- .../modules/thunder_fia/thunder_fia.install | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 modules/thunder_article/modules/thunder_fia/thunder_fia.install diff --git a/modules/thunder_article/modules/thunder_fia/thunder_fia.install b/modules/thunder_article/modules/thunder_fia/thunder_fia.install new file mode 100644 index 000000000..f2575e95f --- /dev/null +++ b/modules/thunder_article/modules/thunder_fia/thunder_fia.install @@ -0,0 +1,18 @@ +install([ + 'config_update', + ]); + + /** @var Drupal\config_update\ConfigRevertInterface $configReverter */ + $configUpdate = \Drupal::service('config_update.config_update'); + + if (empty($configUpdate->getFromActive('entity_view_mode', 'user.facebook_instant_articles_rss'))) { + $configUpdate->import('entity_view_mode', 'user.facebook_instant_articles_rss'); + } + +} From fed850e7d24b8c8799dc4361cccdee19254d2a73 Mon Sep 17 00:00:00 2001 From: Stefan Freudenberg Date: Tue, 21 Feb 2017 08:28:04 +0100 Subject: [PATCH 5/5] Add file level documentation --- .../thunder_article/modules/thunder_fia/thunder_fia.install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/thunder_article/modules/thunder_fia/thunder_fia.install b/modules/thunder_article/modules/thunder_fia/thunder_fia.install index f2575e95f..a9101929b 100644 --- a/modules/thunder_article/modules/thunder_fia/thunder_fia.install +++ b/modules/thunder_article/modules/thunder_fia/thunder_fia.install @@ -1,5 +1,10 @@