Search This Blog

Tuesday, 20 March 2018

Creating Custom Block in DRUPAL 8

Code:
FILE NAME: LanguageSwitcher.php same as Class name
Path : custom_module/src/Plugin/Block


<?php
namespace Drupal\custom_modulename\Plugin\Block;

use Drupal\Core\Block\BlockBase;
/**
* Provides custom block
*
* @Block(
* id = "language_switcher",
* admin_label = @Translation("LanguageSwitcher"),
* category = @Translation("Custom Plugin"),
* )
*/

class LanguageSwitcher extends BlockBase {


public function build() {

$custom_switcher = "<ul><li>Hello</li></ul>";

return array(
      '#markup' => $this->t($custom_switcher),
    );
}
}

No comments:

Post a Comment

First HTML blog

Hello there


echo 'dddd';
?>

Js to show Hide Content

Js: var showChar = 250;  // How many characters are shown by default     var ellipsestext = "...";     var moretext = "Sh...