Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
975 B
3
Indexable
Never
// modules/custom/my_custom_module/src/Plugin/Block/MyCustomBlock.php
namespace Drupal\my_custom_module\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Provides a custom block.
 *
 * @Block(
 *   id = "my_custom_block",
 *   admin_label = @Translation("My Custom Block"),
 *   category = @Translation("Custom")
 * )
 */
class MyCustomBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    // Build the output of the block.
    $output = [
      '#type' => 'link',
      '#title' => '',
      '#url' => '/custom-all-pages',
      '#attributes' => [
        'class' => ['custom-block-link'],
      ],
      '#wrapper_attributes' => [
        'class' => ['custom-block-wrapper'],
      ],
    ];

    // You can render an image or any other content inside the link if needed.
    // For example:
    // $output['#title'] = [
    //   '#markup' => '<img src="/path/to/image.png" alt="My Image" />',
    // ];

    return $output;
  }

}
Leave a Comment