Untitled
unknown
plain_text
2 years ago
975 B
9
Indexable
// 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;
}
}Editor is loading...
Leave a Comment