What Is GitFlow?
GitFlow is a branching model for Git, created by Vincent Driessen. It has attracted a lot of attention because it is very well suited to collaboration and scaling the development team.
Install Drush Using Composer for drupal
Drush is the command line shell and Unix scripting interface for Drupal. The most common way to install Drush is to install it on a per-project basis using Composer. We'll walk through the steps to do that, as well as how to set up the Drush Launcher tool (to make it possible to execute Drush commands without having to specify a full path to the executable).
Run composer require
composer require drush/drush
Once that's completed run the command ./vendor/bin/drush --version
to verify it worked.
How do you place a block in a Twig template
There are various ways you can add blocks to regions in pages in Drupal. You could add it in the block interface, use Panels or Context. But what if you just want to place a block directly in a Twig template?
The simplest way to place a block in a Twig template is to use the Twig Tweak module. Twig Tweak is a very handy module that gives you a range of functions to make theming with Twig easier.
Install Twig Tweak
Get the url of a link field twig drupal
This is how you can get the url of a field link rendered as a string (internal or external).
<a href="{{ node.field_link.get(0).getUrl().toString() }}">{{ node.field_link.get(0).title }}</a>
Get parameter from url in drupal
Short snippet that shows how to get url parameters in drupal . to get query parameter form the url, you can us the following.
If you have the url for example /path?id=x
To get "id" from the url, use:
$id= \Drupal::request()->query->get('id');
Dynamically modify the content displayed in the "empty" area of your view
This is how you can dynamically modify the content displayed in the "empty" area of your "custom" view when it's rendered as a block, based on the configuration's empty header text. Of course you can update the conditions as you think they fit better for you. You can put this into your web/modules/custom/custom.module file.
Although this is of course available from within views admin ui section, sometimes in production for example you might not provide for security reasons the views_ui module making it hard for modifying the empty header text message of a view.
How to create a custom database table with Database Schema in Drupal 8+
Recently i had to build a custom simple table in a drupal 8+ installation that would be used as an api feed bridge between drupal 8+ and a custom api feed service. This is the code i used for the custom table with an extra tip for the date field since there is no date type by default in drupal.
Add javascript to view in drupal
Use global theme javascript only in a few occasions. You should make sure javascript is only used on the right places. This snippet shows you how to load javascript when a specific view is loaded only.
use Drupal\views\ViewExecutable;
/**
* Implements hook_views_pre_render().
*/
function mymodule_views_pre_render(ViewExecutable $view) {
if (isset($view) && ($view->storage->id() == 'view_id')) {
$view->element['#attached']['library'][] = 'mymodule/MYLIBRARY';
}
}
How to Open a Link From <iframe> in the Parent Window
To open the link from <iframe> in the parent window, you can use the <base> tag and set the target attribute to _parent in the <head> section.
How to Add Telephone Links with HTML
Telephone links are the ones that you tap to call a number on phone-capable devices. Of course, some devices are able to recognize phone numbers and provide the linking automatically, but it’s not always so.
In the example below, we use :tel within the HT