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 , 2 June, 2017

Cron on Drupal 8 and Linux

Tags

  • Drupal 8
  • Code
  • Linux
  • Server

Run cron by drush

drush cron

Add cron hook to a custom module.

/**
 * Implement hook_cron()
 */
function MYMODULE_cron() {
  // Your codes.
}

By editor , 23 May, 2017

Redirect a user after login. Redirection on Drupal 8.

Tags

  • Drupal 8
  • Code
  • Module
  • User

To make a redirection after user login, we can use the hook hook_user_login().
Note : You cannot use $form_state->setRedirectUrl() directly in the form alter, since it will be overwritten by UserForm::submitForm().

By editor , 15 May, 2017

Git Tags

Tags

  • Drupal 8
  • Code
  • Git

Add remove git tags.

Create a tag

git tag <TAGNAME>

Push tag

git push origin <TAGNAME>
git push --tags

Pull tags

git tag -l
git checkout tags/<TAGNAME>

By editor , 11 May, 2017

YAML or JSON

Tags

  • Drupal 8
  • Code
  • JSON
  • YAML

Yml vs Json

A make a small test to test YAML vs PHP performance. The result is:

By editor , 24 April, 2017

Drupal 8 Cache contexts

Tags

  • Drupal 8
  • Code
  • Cache

Drupal 8 shiped with a powerfull cache API able to set cache according to a context. correct usage of this cache improve the site preformence greatly.

https://www.drupal.org/docs/8/api/cache-api/cache-contexts
https://www.drupal.org/node/2451661

By editor , 24 April, 2017

Memcache - Install memcached on linux and Drupal.

Tags

  • Drupal 8
  • Code
  • Cache
  • Server

Memcache is caching server allow you to incrise and have great performence on your site. Drupal and memcached work very well and here the full tutorial you need to install and setup memcache server and your drupal instance.

By editor , 29 March, 2017

Few Tips to create a custom module

Tags

  • Drupal 8
  • Code
  • Module

 

Check module exist

if (\Drupal::moduleHandler()->moduleExists('my_module')) {
    $message = 'Module exist.';
}
else {
    $message = 'Not exists.';
}

 

By editor , 16 March, 2017

Avoid Spam form submissions - (Easy way of form Anti-Spam)

Tags

  • Drupal 8
  • Code
  • PHP
  • Form
By editor , 3 March, 2017

Create a View Plugin Without using Database field

Tags

  • Drupal 8
  • Code
  • Module
  • Views

Step 1. Create a custom module and add the HOOK hook_views_data_alter(&$data). Here module : mymodule

Step 2.

By editor , 20 February, 2017

Override 40x System error pages on Drupal 8

Tags

  • Drupal 8
  • Code

You have several mthodes to override 403 / 404 System pages.

Method 1. Set 403 / 404 pages.

You can set the 403 /404 page on "Basic site settings" page
Admin -> Configuration -> System -> Basic site settings
Path /admin/config/system/site-information

Pagination

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