Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

Twig

By editor , 30 September, 2021

Translation API - PHP Twig JavaScript

Tags

  • Drupal 8
  • Drupal 9
  • Translation
  • JavaScript
  • Twig
  • PHP

PHP Class using StringTranslationTrait

StringTranslationTrait allow to get t() and formatPlural() methods
Example:
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
class MyClass {

By editor , 4 June, 2016

Inline template with Drupal 8 and Twig

Tags

  • Drupal 8
  • Code
  • Theming
  • Twig

Example 1. Basic inline template

    $output[] = [
      '#type' => 'inline_template',
      '#template' => '{{ yourvar }}',
      '#context' => [

By editor , 20 May, 2016

Render Custom field with Drupal Renderer

Tags

  • Drupal 8
  • Code
  • Twig
  • Images

Example 1, with FieldPluginBase (\Drupal\views\Plugin\views\field\FieldPluginBase)

By editor , 11 May, 2016

Add twig template to a custom Module, Block or Page

Tags

  • Drupal 8
  • Code
  • Theming
  • Twig

Step 1. Create your module and Block (/tutoriels/107/create-a-simple-block-programmatically)

Step 2. Add your template usin hook_theme()  (here module name = clock)

By editor , 27 April, 2016

Theming : enable Twig templates Debug

Tags

  • Drupal 8
  • Theming
  • Twig

Enable debugging

You enable Twig Debugging in sites/default/services.yml.
(If services.yml does not yet exist; copy default.services.yml and rename it to services.yml.)

parameters:
 twig.config:
  debug: true

By editor , 20 March, 2016

Drupal 8 Theming with Twig

Tags

  • Drupal 8
  • Twig
  • Theming

Print : {{ variable_to_print }}
Code : {% codes %}
Comment : {# Comments #}
 

Twig

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer