diff --git a/composer.json b/composer.json index c288cddea..30d136ee8 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,7 @@ "drupal/adminimal_theme": "^1.6", "drupal/autocomplete_deluxe": "^2.0@RC", "drupal/better_formats": "1.x-dev", + "drupal/block_field": "^1.0@RC", "drupal/config_ignore": "^2.3", "drupal/core-composer-scaffold": "^9.1", "drupal/core-project-message": "^9.1", diff --git a/composer.lock b/composer.lock index c2328f945..256db9ca8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "411b9feab71236a0ae70fe6285d55a59", + "content-hash": "437c0616f1ed936cd2b760554b12488e", "packages": [ { "name": "asm89/stack-cors", @@ -1618,6 +1618,70 @@ "source": "https://git.drupalcode.org/project/better_formats" } }, + { + "name": "drupal/block_field", + "version": "1.0.0-rc1", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/block_field.git", + "reference": "8.x-1.0-rc1" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/block_field-8.x-1.0-rc1.zip", + "reference": "8.x-1.0-rc1", + "shasum": "a366cb012ece9987404168a4570c79f701e7819a" + }, + "require": { + "drupal/core": "^8.7.7 || ^9" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "8.x-1.0-rc1", + "datestamp": "1588279781", + "security-coverage": { + "status": "not-covered", + "message": "RC releases are not covered by Drupal security advisories." + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Berdir", + "homepage": "https://www.drupal.org/user/214652" + }, + { + "name": "acbramley", + "homepage": "https://www.drupal.org/user/1036766" + }, + { + "name": "fenstrat", + "homepage": "https://www.drupal.org/user/362649" + }, + { + "name": "jrockowitz", + "homepage": "https://www.drupal.org/user/371407" + }, + { + "name": "michaellander", + "homepage": "https://www.drupal.org/user/636494" + }, + { + "name": "paulocs", + "homepage": "https://www.drupal.org/user/3640109" + } + ], + "description": "Provides a field that allows a content entity to create and configure custom block instances.", + "homepage": "https://www.drupal.org/project/block_field", + "support": { + "source": "https://git.drupalcode.org/project/block_field" + } + }, { "name": "drupal/config_filter", "version": "2.2.0", @@ -3128,16 +3192,16 @@ }, { "name": "drush/drush", - "version": "10.4.2", + "version": "10.4.3", "source": { "type": "git", "url": "https://github.com/drush-ops/drush.git", - "reference": "0d48a046f5511dd8fda10ac3376b97bb65a2b7ec" + "reference": "472ce3e0ac48b418f8168a053b3bcb4c8582bf99" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/drush-ops/drush/zipball/0d48a046f5511dd8fda10ac3376b97bb65a2b7ec", - "reference": "0d48a046f5511dd8fda10ac3376b97bb65a2b7ec", + "url": "https://api.github.com/repos/drush-ops/drush/zipball/472ce3e0ac48b418f8168a053b3bcb4c8582bf99", + "reference": "472ce3e0ac48b418f8168a053b3bcb4c8582bf99", "shasum": "" }, "require": { @@ -3261,7 +3325,7 @@ "irc": "irc://irc.freenode.org/drush", "issues": "https://github.com/drush-ops/drush/issues", "slack": "https://drupal.slack.com/messages/C62H9CWQM", - "source": "https://github.com/drush-ops/drush/tree/10.4.2" + "source": "https://github.com/drush-ops/drush/tree/10.4.3" }, "funding": [ { @@ -3269,7 +3333,7 @@ "type": "github" } ], - "time": "2021-04-06T03:37:46+00:00" + "time": "2021-04-14T14:08:05+00:00" }, { "name": "egulias/email-validator", @@ -3335,28 +3399,29 @@ }, { "name": "enlightn/security-checker", - "version": "v1.7.0", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/enlightn/security-checker.git", - "reference": "1ac108ba278ba0c2e71d2ce2ac4fac07ed6e8a29" + "reference": "2054fbce2f8df681c8f71b36656222bcd241b77f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/enlightn/security-checker/zipball/1ac108ba278ba0c2e71d2ce2ac4fac07ed6e8a29", - "reference": "1ac108ba278ba0c2e71d2ce2ac4fac07ed6e8a29", + "url": "https://api.github.com/repos/enlightn/security-checker/zipball/2054fbce2f8df681c8f71b36656222bcd241b77f", + "reference": "2054fbce2f8df681c8f71b36656222bcd241b77f", "shasum": "" }, "require": { "ext-json": "*", - "ext-zip": "*", "guzzlehttp/guzzle": "^6.3|^7.0", "php": ">=5.6", "symfony/console": "^3.4|^4|^5", "symfony/finder": "^3|^4|^5", + "symfony/process": "^3.4|^4|^5", "symfony/yaml": "^3.4|^4|^5" }, "require-dev": { + "ext-zip": "*", "friendsofphp/php-cs-fixer": "^2.18", "phpunit/phpunit": "^5.5|^6|^7|^8|^9" }, @@ -3394,9 +3459,9 @@ ], "support": { "issues": "https://github.com/enlightn/security-checker/issues", - "source": "https://github.com/enlightn/security-checker/tree/v1.7.0" + "source": "https://github.com/enlightn/security-checker/tree/v1.8.0" }, - "time": "2021-03-03T11:56:26+00:00" + "time": "2021-04-19T07:13:16+00:00" }, { "name": "ezyang/htmlpurifier", @@ -9028,11 +9093,11 @@ }, { "name": "drupal/coder", - "version": "8.3.12", + "version": "8.3.13", "source": { "type": "git", "url": "https://git.drupalcode.org/project/coder.git", - "reference": "719ddb16aec2e5da4ce274bf3bf8450caef564d4" + "reference": "d3286d571b19633cc296d438c36b9aed195de43c" }, "require": { "ext-mbstring": "*", @@ -9042,7 +9107,7 @@ "symfony/yaml": ">=2.0.5" }, "require-dev": { - "phpstan/phpstan": "^0.12.51", + "phpstan/phpstan": "^0.12.63", "phpunit/phpunit": "^6.0 || ^7.0" }, "type": "phpcodesniffer-standard", @@ -9067,7 +9132,7 @@ "issues": "https://www.drupal.org/project/issues/coder", "source": "https://www.drupal.org/project/coder" }, - "time": "2020-12-06T09:34:55+00:00" + "time": "2021-02-06T10:44:32+00:00" }, { "name": "drupal/content_fixtures", @@ -10053,7 +10118,7 @@ }, { "name": "os2loop/os2loop_fixtures", - "version": "dev-feature/LOOP-832-site-config", + "version": "dev-feature/frontpage-views", "dist": { "type": "path", "url": "web/profiles/custom/os2loop/modules/os2loop_fixtures", @@ -10468,16 +10533,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.83", + "version": "0.12.84", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "4a967cec6efb46b500dd6d768657336a3ffe699f" + "reference": "9c43f15da8798c8f30a4b099e6a94530a558cfd5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/4a967cec6efb46b500dd6d768657336a3ffe699f", - "reference": "4a967cec6efb46b500dd6d768657336a3ffe699f", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9c43f15da8798c8f30a4b099e6a94530a558cfd5", + "reference": "9c43f15da8798c8f30a4b099e6a94530a558cfd5", "shasum": "" }, "require": { @@ -10508,7 +10573,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/0.12.83" + "source": "https://github.com/phpstan/phpstan/tree/0.12.84" }, "funding": [ { @@ -10524,7 +10589,7 @@ "type": "tidelift" } ], - "time": "2021-04-03T15:35:45+00:00" + "time": "2021-04-19T17:10:54+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", @@ -12657,6 +12722,7 @@ "stability-flags": { "drupal/autocomplete_deluxe": 5, "drupal/better_formats": 20, + "drupal/block_field": 5, "drupal/flag": 10, "drupal/masquerade": 10, "drupal/theme_switcher": 20 diff --git a/config/sync/core.entity_form_display.paragraph.os2loop_section_page_views_refer.default.yml b/config/sync/core.entity_form_display.paragraph.os2loop_section_page_views_refer.default.yml index a6572814e..e1af03180 100644 --- a/config/sync/core.entity_form_display.paragraph.os2loop_section_page_views_refer.default.yml +++ b/config/sync/core.entity_form_display.paragraph.os2loop_section_page_views_refer.default.yml @@ -3,23 +3,26 @@ langcode: en status: true dependencies: config: - - field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_view + - field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_block - field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_view_header - field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_view_text - paragraphs.paragraphs_type.os2loop_section_page_views_refer module: + - block_field - text - - viewsreference id: paragraph.os2loop_section_page_views_refer.default targetEntityType: paragraph bundle: os2loop_section_page_views_refer mode: default content: - os2loop_section_page_view: - weight: 2 - settings: { } + os2loop_section_page_block: + weight: 3 + settings: + plugin_id: '' + settings: { } + configuration_form: full third_party_settings: { } - type: viewsreference_select + type: block_field_default region: content os2loop_section_page_view_header: weight: 0 diff --git a/config/sync/core.entity_view_display.paragraph.os2loop_section_page_views_refer.default.yml b/config/sync/core.entity_view_display.paragraph.os2loop_section_page_views_refer.default.yml index 4b89b2e15..6f2af73ed 100644 --- a/config/sync/core.entity_view_display.paragraph.os2loop_section_page_views_refer.default.yml +++ b/config/sync/core.entity_view_display.paragraph.os2loop_section_page_views_refer.default.yml @@ -3,26 +3,24 @@ langcode: en status: true dependencies: config: - - field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_view + - field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_block - field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_view_header - field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_view_text - paragraphs.paragraphs_type.os2loop_section_page_views_refer module: + - block_field - text - - viewsreference id: paragraph.os2loop_section_page_views_refer.default targetEntityType: paragraph bundle: os2loop_section_page_views_refer mode: default content: - os2loop_section_page_view: - weight: 2 + os2loop_section_page_block: + weight: 3 label: hidden - settings: - plugin_types: - - block + settings: { } third_party_settings: { } - type: viewsreference_formatter + type: block_field region: content os2loop_section_page_view_header: weight: 0 diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml index a8ad5bc25..e8f9e1ca9 100644 --- a/config/sync/core.extension.yml +++ b/config/sync/core.extension.yml @@ -1,6 +1,7 @@ module: autocomplete_deluxe: 0 block: 0 + block_field: 0 breakpoint: 0 ckeditor: 0 comment: 0 @@ -26,6 +27,7 @@ module: node: 0 os2loop_documents: 0 os2loop_external: 0 + os2loop_lists: 0 os2loop_menu: 0 os2loop_page: 0 os2loop_post: 0 diff --git a/config/sync/field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_block.yml b/config/sync/field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_block.yml new file mode 100644 index 000000000..3bd5d361f --- /dev/null +++ b/config/sync/field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_block.yml @@ -0,0 +1,36 @@ +uuid: 8007b015-6286-40ad-9725-902927e0c469 +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.os2loop_section_page_block + - paragraphs.paragraphs_type.os2loop_section_page_views_refer + module: + - block_field +id: paragraph.os2loop_section_page_views_refer.os2loop_section_page_block +field_name: os2loop_section_page_block +entity_type: paragraph +bundle: os2loop_section_page_views_refer +label: 'Block element' +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + selection: blocks + selection_settings: + plugin_ids: + 'views_block:os2loop_section_page_most_viewed-block_2': 'views_block:os2loop_section_page_most_viewed-block_2' + 'views_block:os2loop_section_page_most_viewed-block_1': 'views_block:os2loop_section_page_most_viewed-block_1' + 'views_block:os2loop_section_page_most_viewed-block_4': 'views_block:os2loop_section_page_most_viewed-block_4' + 'views_block:os2loop_section_page_most_viewed-block_3': 'views_block:os2loop_section_page_most_viewed-block_3' + 'views_block:os2loop_section_page_newest_content-block_2': 'views_block:os2loop_section_page_newest_content-block_2' + 'views_block:os2loop_section_page_newest_content-block_1': 'views_block:os2loop_section_page_newest_content-block_1' + 'views_block:os2loop_section_page_newest_content-block_4': 'views_block:os2loop_section_page_newest_content-block_4' + 'views_block:os2loop_section_page_newest_content-block_3': 'views_block:os2loop_section_page_newest_content-block_3' + 'views_block:os2loop_section_page_user_favourites-block_1': 'views_block:os2loop_section_page_user_favourites-block_1' + os2loop_list_user_expert_content: os2loop_list_user_expert_content + os2loop_list_user_profession_content: os2loop_list_user_profession_content + 'views_exposed_filter_block:os2loop_search_db-page_1': 'views_exposed_filter_block:os2loop_search_db-page_1' +field_type: block_field diff --git a/config/sync/field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_view.yml b/config/sync/field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_view.yml deleted file mode 100644 index 09ab8cde1..000000000 --- a/config/sync/field.field.paragraph.os2loop_section_page_views_refer.os2loop_section_page_view.yml +++ /dev/null @@ -1,45 +0,0 @@ -uuid: 316095df-830b-4e50-a87a-9ed68eee788f -langcode: en -status: true -dependencies: - config: - - field.storage.paragraph.os2loop_section_page_view - - paragraphs.paragraphs_type.os2loop_section_page_views_refer - module: - - viewsreference -id: paragraph.os2loop_section_page_views_refer.os2loop_section_page_view -field_name: os2loop_section_page_view -entity_type: paragraph -bundle: os2loop_section_page_views_refer -label: List -description: '' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: - handler: 'default:view' - handler_settings: - target_bundles: null - auto_create: 0 - plugin_types: - block: block - default: 0 - page: 0 - feed: 0 - preselect_views: - os2loop_section_page_most_viewed: os2loop_section_page_most_viewed - os2loop_section_page_newest_content: os2loop_section_page_newest_content - os2loop_section_page_user_favourites: os2loop_section_page_user_favourites - comment: 0 - comments_recent: 0 - message: 0 - os2loop_search_db: 0 - taxonomy_term: 0 - enabled_settings: - argument: argument - limit: limit - offset: 0 - pager: 0 - title: 0 -field_type: viewsreference diff --git a/config/sync/field.storage.paragraph.os2loop_section_page_block.yml b/config/sync/field.storage.paragraph.os2loop_section_page_block.yml new file mode 100644 index 000000000..f2113ea50 --- /dev/null +++ b/config/sync/field.storage.paragraph.os2loop_section_page_block.yml @@ -0,0 +1,19 @@ +uuid: f6f21713-b8eb-48c4-bd37-1b2a7988ec55 +langcode: en +status: true +dependencies: + module: + - block_field + - paragraphs +id: paragraph.os2loop_section_page_block +field_name: os2loop_section_page_block +entity_type: paragraph +type: block_field +settings: { } +module: block_field +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/config/sync/field.storage.paragraph.os2loop_section_page_view.yml b/config/sync/field.storage.paragraph.os2loop_section_page_view.yml deleted file mode 100644 index 9a7fc316f..000000000 --- a/config/sync/field.storage.paragraph.os2loop_section_page_view.yml +++ /dev/null @@ -1,21 +0,0 @@ -uuid: 5ea6fd5d-3855-478b-8738-675c49a4789b -langcode: en -status: true -dependencies: - module: - - paragraphs - - views - - viewsreference -id: paragraph.os2loop_section_page_view -field_name: os2loop_section_page_view -entity_type: paragraph -type: viewsreference -settings: - target_type: view -module: viewsreference -locked: false -cardinality: 1 -translatable: true -indexes: { } -persist_with_no_fields: false -custom_storage: false diff --git a/web/profiles/custom/os2loop/modules/os2loop_lists/os2loop_lists.info.yml b/web/profiles/custom/os2loop/modules/os2loop_lists/os2loop_lists.info.yml new file mode 100644 index 000000000..b73e15352 --- /dev/null +++ b/web/profiles/custom/os2loop/modules/os2loop_lists/os2loop_lists.info.yml @@ -0,0 +1,7 @@ +name: 'os2loop_lists' +type: module +description: 'Complex db queries that should not be covered by views module output in blocks' +# Used only for development and testing. +hidden: true +core_version_requirement: ^9 +package: 'OS2Loop' diff --git a/web/profiles/custom/os2loop/modules/os2loop_lists/os2loop_lists.module b/web/profiles/custom/os2loop/modules/os2loop_lists/os2loop_lists.module new file mode 100644 index 000000000..d94455d46 --- /dev/null +++ b/web/profiles/custom/os2loop/modules/os2loop_lists/os2loop_lists.module @@ -0,0 +1,24 @@ + [ + 'variables' => ['data' => NULL], + 'template' => 'os2loop-lists-expert', + ], + 'os2loop_lists_profession' => [ + 'variables' => ['data' => NULL], + 'template' => 'os2loop-lists-profession', + ], + ]; +} diff --git a/web/profiles/custom/os2loop/modules/os2loop_lists/os2loop_lists.services.yml b/web/profiles/custom/os2loop/modules/os2loop_lists/os2loop_lists.services.yml new file mode 100644 index 000000000..ea038962c --- /dev/null +++ b/web/profiles/custom/os2loop/modules/os2loop_lists/os2loop_lists.services.yml @@ -0,0 +1,6 @@ +services: + Drupal\os2loop_lists\Helper\Helper: + class: Drupal\os2loop_lists\Helper\Helper + arguments: + - '@entity_type.manager' + - '@current_user' diff --git a/web/profiles/custom/os2loop/modules/os2loop_lists/src/Helper/Helper.php b/web/profiles/custom/os2loop/modules/os2loop_lists/src/Helper/Helper.php new file mode 100644 index 000000000..6ee7c9159 --- /dev/null +++ b/web/profiles/custom/os2loop/modules/os2loop_lists/src/Helper/Helper.php @@ -0,0 +1,134 @@ +userStorage = $entityTypeManager->getStorage('user'); + $this->currentUser = $currentUser; + $this->entityTypeManager = $entityTypeManager; + } + + /** + * Get content related by subject. + * + * @return array + * An array of content that shares subject term with the logged in users + * expertises terms. + */ + public function getContentByUserExpertise(): array { + $user_expertises = $this->getCurrentUserExpertisesId(); + if (empty($user_expertises)) { + return []; + } + + return $this->getList('os2loop_shared_subject', $user_expertises); + } + + /** + * Get content related by profession. + * + * @return array + * An array of content that shares profession terms with the logged in + * users professions terms. + */ + public function getContentByUserProfession(): array { + $user_professions = $this->getCurrentUserProfessionsId(); + if (empty($user_professions)) { + return []; + } + + return $this->getList('os2loop_shared_profession', $user_professions); + } + + /** + * The logged in users expertises. + * + * @return array + * An array of logged in users expertise taxonomy term ids. + */ + private function getCurrentUserExpertisesId(): array { + $user = $this->userStorage->load($this->currentUser->id()); + /** @var \Drupal\user\UserInterface $user */ + $expertises = $user->get('os2loop_user_areas_of_expertise')->getValue(); + return array_column($expertises, 'target_id'); + } + + /** + * The logged in users professions. + * + * @return array + * An array of logged in users profession taxonomy term ids. + */ + private function getCurrentUserProfessionsId(): array { + $user = $this->userStorage->load($this->currentUser->id()); + /** @var \Drupal\user\UserInterface $user */ + $professions = $user->get('os2loop_user_professions')->getValue(); + return array_column($professions, 'target_id'); + } + + /** + * Build list. + * + * @param string $field_name + * The name of the field to make condition for. + * @param array $taxonomy_terms + * The condition of the field. + * + * @return array + * A list of nodes with shared taxonomy terms. + */ + private function getList(string $field_name, array $taxonomy_terms): array { + return $this->entityTypeManager + ->getListBuilder('node') + ->getStorage() + ->loadByProperties([ + 'type' => 'os2loop_question', + 'status' => 1, + $field_name => $taxonomy_terms, + ]); + } + +} diff --git a/web/profiles/custom/os2loop/modules/os2loop_lists/src/Plugin/Block/Os2loopListsExpertBlock.php b/web/profiles/custom/os2loop/modules/os2loop_lists/src/Plugin/Block/Os2loopListsExpertBlock.php new file mode 100644 index 000000000..c953a63c0 --- /dev/null +++ b/web/profiles/custom/os2loop/modules/os2loop_lists/src/Plugin/Block/Os2loopListsExpertBlock.php @@ -0,0 +1,80 @@ +helper = $helper; + } + + /** + * Create block. + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * Container interface. + * @param array $configuration + * Block configuration. + * @param string $plugin_id + * Block plugin id. + * @param mixed $plugin_definition + * Block plugin definition. + * + * @return static + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): Os2loopListsExpertBlock { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get(Helper::class) + ); + } + + /** + * {@inheritdoc} + */ + public function build() { + $data = $this->helper->getContentByUserExpertise(); + + return [ + '#type' => 'markup', + '#theme' => 'os2loop_lists_expert', + '#data' => $data, + ]; + } + +} diff --git a/web/profiles/custom/os2loop/modules/os2loop_lists/src/Plugin/Block/Os2loopListsProfessionBlock.php b/web/profiles/custom/os2loop/modules/os2loop_lists/src/Plugin/Block/Os2loopListsProfessionBlock.php new file mode 100644 index 000000000..e60d40adc --- /dev/null +++ b/web/profiles/custom/os2loop/modules/os2loop_lists/src/Plugin/Block/Os2loopListsProfessionBlock.php @@ -0,0 +1,80 @@ +helper = $helper; + } + + /** + * Create block. + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * Container interface. + * @param array $configuration + * Block configuration. + * @param string $plugin_id + * Block plugin id. + * @param mixed $plugin_definition + * Block plugin definition. + * + * @return static + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): Os2loopListsProfessionBlock { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get(Helper::class) + ); + } + + /** + * {@inheritdoc} + */ + public function build() { + $data = $this->helper->getContentByUserProfession(); + + return [ + '#type' => 'markup', + '#theme' => 'os2loop_lists_profession', + '#data' => $data, + ]; + } + +} diff --git a/web/profiles/custom/os2loop/modules/os2loop_lists/templates/os2loop-lists-expert.html.twig b/web/profiles/custom/os2loop/modules/os2loop_lists/templates/os2loop-lists-expert.html.twig new file mode 100644 index 000000000..ed40874b6 --- /dev/null +++ b/web/profiles/custom/os2loop/modules/os2loop_lists/templates/os2loop-lists-expert.html.twig @@ -0,0 +1,25 @@ +{# +/** + * @file + * Display list of content that the logged in user should be an expert on. + * + * Available variables: + * - data: A list of nodes + */ +#} +{% if data is empty %} +
+
+ {{ 'No content related to your user'|t }} +
+
+{% else %} + {% for node in data %} +
+
+
{{ node.type.entity.label }}
+

{{ node.title() }}

+
+
+ {% endfor %} +{% endif %} diff --git a/web/profiles/custom/os2loop/modules/os2loop_lists/templates/os2loop-lists-profession.html.twig b/web/profiles/custom/os2loop/modules/os2loop_lists/templates/os2loop-lists-profession.html.twig new file mode 100644 index 000000000..670bdb419 --- /dev/null +++ b/web/profiles/custom/os2loop/modules/os2loop_lists/templates/os2loop-lists-profession.html.twig @@ -0,0 +1,25 @@ +{# +/** + * @file + * Display list of content that is related to the users profession. + * + * Available variables: + * - data: A list of nodes + */ +#} +{% if data is empty %} +
+
+ {{ 'No content related to your user'|t }} +
+
+{% else %} + {% for node in data %} +
+
+
{{ node.type.entity.label }}
+

{{ node.title() }}

+
+
+ {% endfor %} +{% endif %} diff --git a/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content/field--os2loop-section-page-paragraph.html.twig b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content/field--os2loop-section-page-paragraph.html.twig new file mode 100644 index 000000000..f4674e209 --- /dev/null +++ b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content/field--os2loop-section-page-paragraph.html.twig @@ -0,0 +1,85 @@ +{# +/** + * @file + * Default theme implementation for a field. + * + * To override output, copy the "field.html.twig" from the templates directory + * to your theme's directory and customize it, just like customizing other + * Drupal templates such as page.html.twig or node.html.twig. + * + * Instead of overriding the theming for all fields, you can also just override + * theming for a subset of fields using + * @link themeable Theme hook suggestions. @endlink For example, + * here are some theme hook suggestions that can be used for a field_foo field + * on an article node type: + * - field--node--field-foo--article.html.twig + * - field--node--field-foo.html.twig + * - field--node--article.html.twig + * - field--field-foo.html.twig + * - field--text-with-summary.html.twig + * - field.html.twig + * + * Available variables: + * - attributes: HTML attributes for the containing element. + * - label_hidden: Whether to show the field label or not. + * - title_attributes: HTML attributes for the title. + * - label: The label for the field. + * - multiple: TRUE if a field can contain multiple items. + * - items: List of all the field items. Each item contains: + * - attributes: List of HTML attributes for each item. + * - content: The field item's content. + * - entity_type: The entity type to which the field belongs. + * - field_name: The name of the field. + * - field_type: The type of the field. + * - label_display: The display settings for the label. + * + * @see template_preprocess_field() + * + * @ingroup themeable + */ +#} +{% set title_classes = [ + label_display == 'visually_hidden' ? 'visually-hidden', + label_display == 'inline' ? 'os2loop-title-text-inline', + label_display != 'inline' ? 'os2loop-title-text', + ] +%} +{% if label_hidden %} + {% if multiple %} + + {% for item in items %} + {{ item.content }} + {% endfor %} + + {% else %} + {% for item in items %} + {{ item.content }} + {% endfor %} + {% endif %} +{% elseif label_display == 'inline' %} + + {{ label }}: + {% if multiple %} + + {% endif %} + {% for item in items %} + {{ item.content }} + {% endfor %} + {% if multiple %} + + {% endif %} + +{% else %} + + {{ label }} + {% if multiple %} +
+ {% endif %} + {% for item in items %} + {{ item.content }}
+ {% endfor %} + {% if multiple %} + + {% endif %} + +{% endif %} diff --git a/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content/field--os2loop-section-page-view-header.html.twig b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content/field--os2loop-section-page-view-header.html.twig new file mode 100644 index 000000000..1228203a1 --- /dev/null +++ b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content/field--os2loop-section-page-view-header.html.twig @@ -0,0 +1,43 @@ +{# +/** + * @file + * Default theme implementation for a field. + * + * To override output, copy the "field.html.twig" from the templates directory + * to your theme's directory and customize it, just like customizing other + * Drupal templates such as page.html.twig or node.html.twig. + * + * Instead of overriding the theming for all fields, you can also just override + * theming for a subset of fields using + * @link themeable Theme hook suggestions. @endlink For example, + * here are some theme hook suggestions that can be used for a field_foo field + * on an article node type: + * - field--node--field-foo--article.html.twig + * - field--node--field-foo.html.twig + * - field--node--article.html.twig + * - field--field-foo.html.twig + * - field--text-with-summary.html.twig + * - field.html.twig + * + * Available variables: + * - attributes: HTML attributes for the containing element. + * - label_hidden: Whether to show the field label or not. + * - title_attributes: HTML attributes for the title. + * - label: The label for the field. + * - multiple: TRUE if a field can contain multiple items. + * - items: List of all the field items. Each item contains: + * - attributes: List of HTML attributes for each item. + * - content: The field item's content. + * - entity_type: The entity type to which the field belongs. + * - field_name: The name of the field. + * - field_type: The type of the field. + * - label_display: The display settings for the label. + * + * @see template_preprocess_field() + * + * @ingroup themeable + */ +#} +{% for item in items %} + {{ item.content }} +{% endfor %} diff --git a/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content/node--list-display.html.twig b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content/node--list-display.html.twig index d1d0bfc8d..be774751a 100644 --- a/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content/node--list-display.html.twig +++ b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/content/node--list-display.html.twig @@ -75,6 +75,6 @@