Skip to main content
Home
Custom Software Development
  • Consulting
    • All Consulting Services
    • Ruby on Rails
    • ReactJs
    • Drupal
    • Pricing
  • Hosting
    • All Managed Appliances
    • Advanced CRM & Email Client
    • Jenkins
    • SMT
    • Pricing
  • About us
    • Our Technology Stack
    • Our Process
    • Our Team
    • Case Studies
    • Contact Us
Vote up!

5

Vote down!

Drupal 9.5: How to render a block from a controller

By admin on 2025-02-16
 
Drupal
Engineering Blog
  • Log in or register to post comments

Based on this excellent stackoverflow answer.

$bid = ??? // Get the block id through config, SQL or some other means
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->
  getViewBuilder('block_content')->view($block);
return $render;

.

Please login or register to post a comment.

User account menu

  • Register
  • Log in

Pages

  • Issues
  • Engineering Blog
  • Site Updates
  • Tags
  • Careers
  • Contact us
  • English
  • Español
  • Português
  • Russian
  • LinkedIn linkedin logo
  • Youtube youtube logo
Copyright (c) 2023 Wasya Co
Terms & Conditions

  201 W 5th St 11th Floor, Austin, TX 78701