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 , 12 January, 2016

Set the initial Auto Increment value

Tags

  • Drupal 8
  • Code
  • Database

Example:

  $con = Drupal\Core\Database\Database::getConnection();
  $start_value = 100000;
  $query = "ALTER TABLE {the_table} AUTO_INCREMENT = $start_value";
  $con->query($query);

By editor , 12 January, 2016

Display contents using Drupal8 Render API

Tags

  • Drupal 8
  • Code
  • Theming

 

Render arrays

 

By editor , 6 January, 2016

Git - Create new branche, push and merge

Tags

  • Git
  • Code

git checkout -b // TO TEST


git branch <branche>  // TO TEST

By editor , 24 December, 2015

Drupal 8 Global variables - Globals

Tags

  • Drupal 8
  • Code

 

 

By editor , 24 December, 2015

Build a From from another Form

Tags

  • Drupal 8
  • Code
  • Form

Example : (From user login block)

By editor , 23 December, 2015

Delete a source string and the target translations in Drupal 8

Tags

  • Drupal 8
  • Code
  • Translation

As you haven't a Delete button on interface translation page, you can't do that from the translation interface. But you can do in a small custom module.

Example : Delete string ID 346, 'Home'

      $lid = 346;

By editor , 23 December, 2015

Page Redirection on Drupal 8 / 9

Tags

  • Drupal 8
  • Code
  • Drupal 9

Example 1. Redirect to the front page:

    return new \Symfony\Component\HttpFoundation\RedirectResponse(\Drupal::url('<front>'));

Example 2. Redirect to a route path (user page):

By editor , 22 December, 2015

Create and Render link in drupal_set_message

Tags

  • Drupal 8
  • Code

Example : Password Reset Link.
      $link = \Drupal::l(t('Link'), \Drupal\Core\Url::fromRoute('user.pass'));
      drupal_set_message(t("Password Reset Link : @link!", ['@link!' => $link]));

 

By editor , 18 December, 2015

Filter input text with Drupal Text Formats

Tags

  • Drupal 8
  • Code

Like Drupal 7, you can use check_markup();

CAUTION : This must only use on a rendered HTML page

By editor , 17 December, 2015

Move a file in drupal 8

Tags

  • Drupal 8
  • Code

file_move(FileInterface $source, $destination = NULL, $replace = FILE_EXISTS_RENAME)

Example:

$file = \Drupal\file\Entity\File::load($fid);
file_move(FileInterface $source, 'path/to/destination');

Pagination

  • Previous page
  • 15
  • 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