-1

I am using the following code for a block.

  public function build() {
    $current_client = \Drupal::service('user.private_tempstore')->get('epensions');
    $build = [];
    $build['client'] = array(
      '#markup' => $current_client->get('scheme_name').' : '. $current_client->get('sponsor_name'),
    );

    $build['change_link'] = array(
      '#title' => $this->t('Change'),
      '#prefix' => '<br>',
      '#type' => 'link',
      '#url' => Url::fromRoute('epensions.sponsor.selector')
    );

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

  return $build;

  }

I want the results to appear to the right of the account details in Bootstrap and show the same way "My account" & "Log Out" appears.

screenshot

Kindly help.

1

1 Answer 1

0

There are multiple ways you could approach this. Rather than create a new block, one way would be to add the 'change_link' item to the User Account menu, and then use hook_link_alter to add the sponsor_name text in front of the new link.

Another way would be to use the Block Layout settings (admin/structure/block) to position your block in the desired region (wherever the account details are positioned) and give it the desired weight within that region. Then use CSS to float it to the right of the account details.

If you really want to position block output within another block, you could use hook_block_view_alter.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.