Posts

Showing posts from April, 2018

Configure Multisite in Drupal 8

One of the most favourite and  valuable features in drupal is multisite configuration, Drupal 8 provide simple way to create multisite it reduced lots of works. The following steps shows to configure multisite in drupal 8 Should have more than one domain and databases, I am going to use the domain ( www.domain1.com ,  www.domain2.com ) and databases (domain1, domain2). Create two folders in drupal-8/sites/ folder with domain1, domain2 name, the folder path would be like this drupal-8/sites/domain1/ and drupal-8/sites/domain2/ Create files/ folder in both the folder (drupal-8/sites/domain1/files) Copy the default.settings.php file and paste it into the both folder then rename it as settings.php ( drupal-8/sites/domain1/settings.php, drupal-8/sites/domain1/settings.php) Edit the settings.php file for domain1 to adding the database $databases [ 'default' ][ 'default' ] = array (    'dat...

How to load a block programmatically and use in twig file

Add the following code in right preprocess in the .theme file. $block = Block::load('test_block'); $variables['test_block'] = \Drupal::entityTypeManager() ->getViewBuilder('block') ->view($block); Now in your twig file you print test block in following way {{ test_block }}.

How to handle form submission using AJAX in Drupal 8

Image
Here is the buildForm function for creating an AJAX form.   public function buildForm(array $form, FormStateInterface $form_state) {     $form = [];     $form['email'] = [       '#type' => 'textfield',       '#attributes' => ['placeholder'=>'Enter your Email ID'],       '#description' => 'Submit your email address to recieve updates',       '#size' => 100,       '#maxlength' => 150,       '#required' => TRUE,     ];     $form['submit_button'] = [       '#type' => 'submit',       '#name' => 'submit-email',       '#value' => '>',       '#ajax' => [         'callback' => '::processEmail',         'wrapper' => 'thanks-message',         'effect' => 'fade',         'event' =...