Skip to main content
Bounty Ended with 50 reputation awarded by Mojtaba Reyhani
added 8 characters in body
Source Link
oknate
  • 14.5k
  • 4
  • 53
  • 98

you can use markup render arrays like this:

 public function build() {
    $build = [];

    $build['LinkA_url'] = ['#markup' => $this->configuration['LinkA_url']];
    $build['LinkB_url'] = ['#markup' => $this->configuration['LinkB_url']];
  
    return $build;
  }

Then in your twig:

link 1

link 2

  <p><a href="{{ content.LinkA_url }}">link 1</a></p>
  <p><a href="{{ content.LinkB_url }}">link 2</a></p>

then add hook_theme in your .module file:

/**
 * Implements hook_theme().
 */
function my_module_theme() {
  return array(
    'block__my_module' => array(
      'base hook' => 'block'
    ),
  );
}

Otherwise, it won't look in your module's templates folder.

you can use markup render arrays like this:

 public function build() {
    $build = [];

    $build['LinkA_url'] = ['#markup' => $this->configuration['LinkA_url']];
    $build['LinkB_url'] = ['#markup' => $this->configuration['LinkB_url']];
  
    return $build;
  }

Then in your twig:

link 1

link 2

then add hook_theme in your .module file:

/**
 * Implements hook_theme().
 */
function my_module_theme() {
  return array(
    'block__my_module' => array(
      'base hook' => 'block'
    ),
  );
}

Otherwise, it won't look in your module's templates folder.

you can use markup render arrays like this:

 public function build() {
    $build = [];

    $build['LinkA_url'] = ['#markup' => $this->configuration['LinkA_url']];
    $build['LinkB_url'] = ['#markup' => $this->configuration['LinkB_url']];
  
    return $build;
  }

Then in your twig:

  <p><a href="{{ content.LinkA_url }}">link 1</a></p>
  <p><a href="{{ content.LinkB_url }}">link 2</a></p>

then add hook_theme in your .module file:

/**
 * Implements hook_theme().
 */
function my_module_theme() {
  return array(
    'block__my_module' => array(
      'base hook' => 'block'
    ),
  );
}

Otherwise, it won't look in your module's templates folder.

added 36 characters in body
Source Link
oknate
  • 14.5k
  • 4
  • 53
  • 98

you can use markup render arrays like this:

 public function build() {
    $build = [];

    $build['LinkA_url'] = ['#markup' => $this->configuration['LinkA_url']];
    $build['LinkB_url'] = ['#markup' => $this->configuration['LinkB_url']];
  
    return $build;
  }

Then in your twig:

  {{ content.LinkA_url }}<br />
  {{ content.LinkB_url }}<br />

link 1

link 2

then add hook_theme in your .module file:

/**
 * Implements hook_theme().
 */
function my_module_theme() {
  return array(
    'block__my_module' => array(
      'base hook' => 'block'
    ),
  );
}

Otherwise, it won't look in your module's templates folder.

you can use markup render arrays like this:

 public function build() {
    $build = [];

    $build['LinkA_url'] = ['#markup' => $this->configuration['LinkA_url']];
    $build['LinkB_url'] = ['#markup' => $this->configuration['LinkB_url']];
  
    return $build;
  }

Then in your twig:

  {{ content.LinkA_url }}<br />
  {{ content.LinkB_url }}<br />

then add hook_theme in your .module file:

/**
 * Implements hook_theme().
 */
function my_module_theme() {
  return array(
    'block__my_module' => array(
      'base hook' => 'block'
    ),
  );
}

Otherwise, it won't look in your module's templates folder.

you can use markup render arrays like this:

 public function build() {
    $build = [];

    $build['LinkA_url'] = ['#markup' => $this->configuration['LinkA_url']];
    $build['LinkB_url'] = ['#markup' => $this->configuration['LinkB_url']];
  
    return $build;
  }

Then in your twig:

link 1

link 2

then add hook_theme in your .module file:

/**
 * Implements hook_theme().
 */
function my_module_theme() {
  return array(
    'block__my_module' => array(
      'base hook' => 'block'
    ),
  );
}

Otherwise, it won't look in your module's templates folder.

deleted 654 characters in body
Source Link
oknate
  • 14.5k
  • 4
  • 53
  • 98

you can use markup render arrays like this:

 public function build() {
    $build = [];

    $build['LinkA_url'] = ['#markup' => $this->configuration['LinkA_url']];
    $build['LinkB_url'] = ['#markup' => $this->configuration['LinkB_url']];
  
    return $build;
  }

Then in your twig:

  {{ content.LinkA_url }}<br />
  {{ content.LinkB_url }}<br />

To be able to place your template in your module, you need tothen add hook_theme toin your my_module.module like thisfile:

/**
 * Implements hook_theme().
 */
function my_module_theme() {
  return array(
    'block__my_block''block__my_module' => array(
      'base hook' => 'block'
    ),
  );
}

Otherwise, it won't look in your module for blockmodule's templates.

then the template would be "block--my-block.html folder.twig"

my_module
  ├ src
  | └ Plugin
  |    └ Block
  |       └ MyBlock.php
  ├ templates
  |  └ block--my-block.html.twig
  ├ my_module.info.yml
  └ my_module.module

you can use markup render arrays like this:

 public function build() {
    $build = [];

    $build['LinkA_url'] = ['#markup' => $this->configuration['LinkA_url']];
    $build['LinkB_url'] = ['#markup' => $this->configuration['LinkB_url']];
  
    return $build;
  }

Then in your twig:

  {{ content.LinkA_url }}<br />
  {{ content.LinkB_url }}<br />

To be able to place your template in your module, you need to add hook_theme to your my_module.module like this:

/**
 * Implements hook_theme().
 */
function my_module_theme() {
  return array(
    'block__my_block' => array(
      'base hook' => 'block'
    ),
  );
}

Otherwise, it won't look in your module for block templates.

then the template would be "block--my-block.html.twig"

my_module
  ├ src
  | └ Plugin
  |    └ Block
  |       └ MyBlock.php
  ├ templates
  |  └ block--my-block.html.twig
  ├ my_module.info.yml
  └ my_module.module

you can use markup render arrays like this:

 public function build() {
    $build = [];

    $build['LinkA_url'] = ['#markup' => $this->configuration['LinkA_url']];
    $build['LinkB_url'] = ['#markup' => $this->configuration['LinkB_url']];
  
    return $build;
  }

Then in your twig:

  {{ content.LinkA_url }}<br />
  {{ content.LinkB_url }}<br />

then add hook_theme in your .module file:

/**
 * Implements hook_theme().
 */
function my_module_theme() {
  return array(
    'block__my_module' => array(
      'base hook' => 'block'
    ),
  );
}

Otherwise, it won't look in your module's templates folder.

added 237 characters in body
Source Link
oknate
  • 14.5k
  • 4
  • 53
  • 98
Loading
removed new array syntax
Source Link
oknate
  • 14.5k
  • 4
  • 53
  • 98
Loading
Source Link
oknate
  • 14.5k
  • 4
  • 53
  • 98
Loading