Skip to main content
Category:

in this post, I'll show you How to get custom entity data in custom page in drupal 8.

Render the output of a custom entity programmatically

<?php

$entity_type = 'banner';
$banner_id = $banner_item_id;
$view_mode = 'full';

$banner = \Drupal::entityTypeManager()->getStorage($entity_type)->load($banner_id);
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('banner');
$pre_render = $view_builder->view($banner, $view_mode);
$render_output = render($pre_render);

 

Render object of a custom entity programmatically 

$storage = Drupal::entityTypeManager()->getStorage('banner');

$nids = Drupal::entityQuery('banner')->execute();
//Load all nids
$banners = $storage->loadMultiple($nids);
//You can also use
$banners = $storage->loadMultiple();

 

 

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts

Search

Page Facebook