1

I would like to render/load a node's content in my custom block.

This block will have a button which will load/refresh the block and render the data of that node.

I am able to showup my custom block

/**
   * {@inheritdoc}
   */
  public function build() {
    $build = [
        '#theme'    =>  'notification_template',
        '#markup'    =>  'markup notification',
    ];

    $build['#cache']['max-age'] = 0;
    return $build;
  }

In module_name.module

function template_preprocess_notification_template(&$variables) {
    $user = \Drupal::currentUser();
    //my own logic
    //......
}

Above code is working fine, however I am unable to refresh this block via ajax call. I will like to load 1st node's body content in above block.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.