Ich stieß auf ein Problem beim Erstellen eines benutzerdefinierten Blocks. Es gibt andere Blöcke innerhalb desselben Moduls, die hinzugefügt werden können und gut funktionieren.Drupal 8 benutzerdefinierte Block zeigt in Block Liste, kann aber nicht hinzugefügt werden
Hier ist der Code (Dateiname TourLink.php in/modules/custom/custom_blocks/Plugin/Block/ist):
<?php
/**
* Provides a block that links to /tour
*
* @Block(
* id = "tour_link",
* admin_label = @Translation("Tour Link"),
*)
*/
namespace Drupal\custom_blocks\Plugin\Block;
use Drupal\Core\Block\BlockBase;
class TourLink extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
$output = '
<span>test</span>
';
return array(
'#type' => 'markup',
'#markup' => $output,
);
}
}
Vielen Dank im Voraus!
Klassenanmerkungen gehen an _das Ende des Dokumentationsblocks unmittelbar vor der Klassendeklaration_ (siehe [Anmerkungen] (https://api.drupal.org/api/drupal/core%21core.api.php/group/annotation/ 8.2.x)). Ich bin mir nicht sicher, aber vielleicht ist das wirklich wichtig. –
Danke, aber das war es nicht. –