By editor, 16 September, 2016 Question Examples of drupal 8 html elements render and themes Use custom twig template or alter an existence. Create a custom module then use hook_theme() HTML Elements Example : Create a Table $header = ['#','Name', 'Mail']; $data = [ [1,'Name 1', 'Mail1@example.com'], [2,'Name NĀ°2', 'second@example.com'], ]; $output[] = array( '#theme' => 'table', //'#cache' => ['disabled' => TRUE], '#caption' => 'The table caption / Title', '#header' => $header, '#rows' => $data, ); Example : Create a List $output = [ '#theme' => 'item_list', '#list_type' => 'ul', '#title' => 'My List', '#items' => ['Apple', 'Car'], '#attributes' => ['class' => 'myclass'], '#wrapper_attributes' => ['class' => 'my_list_container'], ]; Example: Create a link $output = [ '#title' => $this->t('Examples'), '#type' => 'link', '#url' => Url::fromRoute('examples.description') ]; Example : Tags Drupal 8 Code Theming HTML List render and theming Create HTML Table. render and theming Comments You must have JavaScript enabled to use this form. Your name Subject Comment About text formats Plain text No HTML tags allowed. Lines and paragraphs break automatically. Web page addresses and email addresses turn into links automatically.
Comments