This commit is contained in:
2026-01-24 10:44:29 -06:00
parent efd0d76f9b
commit 8797b7c96e
4 changed files with 6 additions and 73 deletions

View File

@@ -3,4 +3,4 @@ machine_name: archive_tree
type: module type: module
description: 'Provides an Archive tree block.' description: 'Provides an Archive tree block.'
core_version_requirement: ^10 || ^11 core_version_requirement: ^10 || ^11
package: Custom package: Other

View File

@@ -1,4 +1,4 @@
archive_tree_styles: archive_tree:
version: 1.x version: 1.x
css: css:
theme: theme:

View File

@@ -1,67 +0,0 @@
langcode: en
status: true
dependencies:
module:
- node
id: archive_by_year
label: 'Archive by year'
description: 'Lists all content for a given year.'
module: views
display:
page_1:
display_plugin: page
id: page_1
display_title: 'Archive by year'
position: 0
display_options:
path: 'archive-tree/%'
arguments:
created_year:
id: created_year
table: node_field_data
field: created
default_action: empty
exception: ''
title_enable: true
title: 'Archive for year %1'
default_argument_type: fixed
default_argument_options:
argument: ''
summary:
sort_order: asc
number_of_records: 0
format: default_summary
base_path: ''
count: true
limit: 0
plugin_id: date
date_format: 'Y'
granularity: year
filters:
status:
id: status
table: node_field_data
field: status
value: '1'
provider: node
fields:
title:
id: title
table: node_field_data
field: title
label: 'Title'
alter:
make_link: true
path: 'node/[nid]'
sort:
created:
id: created
table: node_field_data
field: created
order: DESC
pager:
type: some
options:
items_per_page: 20
style:
type: default

View File

@@ -2,8 +2,8 @@
namespace Drupal\archive_tree\Plugin\Block; namespace Drupal\archive_tree\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\Attribute\Block; use Drupal\Core\Block\Attribute\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
@@ -13,7 +13,7 @@ use Drupal\node\Entity\NodeType;
* Provides an 'Archive tree' block. * Provides an 'Archive tree' block.
*/ */
#[Block( #[Block(
id: "archive_tree_block", id: "archive_tree",
admin_label: new TranslatableMarkup("Archive tree"), admin_label: new TranslatableMarkup("Archive tree"),
category: new TranslatableMarkup("Menus") category: new TranslatableMarkup("Menus")
)] )]
@@ -64,7 +64,7 @@ class ArchiveTreeBlock extends BlockBase {
$this->configuration['content_types'] = $selected_types; $this->configuration['content_types'] = $selected_types;
} }
public function build() { public function build(): array {
$storage = \Drupal::entityTypeManager()->getStorage('node'); $storage = \Drupal::entityTypeManager()->getStorage('node');
$types = array_filter($this->configuration['content_types']); $types = array_filter($this->configuration['content_types']);
if (empty($types)) { if (empty($types)) {
@@ -123,7 +123,7 @@ class ArchiveTreeBlock extends BlockBase {
'#allowed_tags' => ['details', 'summary', 'a', 'div'], '#allowed_tags' => ['details', 'summary', 'a', 'div'],
'#attached' => [ '#attached' => [
'library' => [ 'library' => [
'archive_tree/archive_tree_styles', 'archive_tree/archive_tree',
], ],
], ],
'#cache' => [ '#cache' => [