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

Code

By editor , 23 November, 2015

Drupal 8 Menu System

Tags

  • Drupal 8
  • Code
  • Settings

1. Define route in module.routing.yml
Exemple :
module.view.settings:
  path: '/url/to/the/page'
  defaults:
    _controller: '\Drupal\module\Controller\Demo::view'
    _title: ''

By editor , 20 November, 2015

Set configuration at the module installation

Tags

  • Drupal 8
  • Code

To set configuration at the module installation

Exemple:
$site_name = \Drupal::config('system.site')->get('name');
// Set the site name.
\Drupal::configFactory()->getEditable('system.site')->set('name', 'My site')->save();

By editor , 20 November, 2015

Return JSON array as resut - Provide Json Interface

Tags

  • Drupal 8
  • Code
  • JSON

You can do that using Symfony JsonResponse.

Exemple 1.
return new \Symfony\Component\HttpFoundation\JsonResponse($array);

By editor , 19 November, 2015

Create a link with Drupal 8 like l() and url() on D7

Tags

  • Drupal 8
  • Code

Exemple:

By editor , 19 November, 2015

Create the module help page on Drupal 8

Tags

  • Drupal 8
  • Code

Here an exemple : Module name : mymodule

By editor , 19 November, 2015

Get the current page URI on Drupal 8

Tags

  • Drupal 8
  • Code

Here an example to get the current page path programmatically in Drupal 8

    $current_url = Url::fromRoute('<current>');
    $path = $current_url->toString();

By editor , 18 November, 2015

Ajax Form

Tags

  • Drupal 8
  • Code
  • Form

Exemple : Field 'username'

By editor , 18 November, 2015

Save user / temporary data on $_SESSION

Tags

  • Drupal 8
  • Code
  • User

Store data on session.

Example:

$session = new \Symfony\Component\HttpFoundation\Session\Session();
$session->set('var_name', $session->get('var_name',0) + 1);
drupal_set_message($session->get('var_name'));

 

By editor , 18 November, 2015

Add CSS stylesheets to a module (CKEditor)

Tags

  • Drupal 8
  • Theming
  • Code
  • Drupal 9

There are several ways to do that.

By editor , 17 November, 2015

Get taxonomy terms of a vocabulary - Drupal 8

Tags

  • Drupal 8
  • Code
  • Taxonomy

Using entityQuery, you can get the taxonomy terms  of a particular vocabulary.

Pagination

  • Previous page
  • 19
  • Next page
Code

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