Posts

Showing posts from 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' =...

What is new in Drupal 8 as compare to Drupal 7

Image
Whether you’re a site builder, module or theme developer, or simply an end user of a Drupal website, Drupal 8 has tons in store for you. This this blog will enumerate the major changes in Drupal 8 for end users, for site builders, for designers and front-end developers, and for back-end developers.                                           Major Improvement in Drupal 8 1. Effortless Authoring 2. Mobile in its DNA 3. New configuration Management  4. Views in Core- Out of the box 5. Better Markup with HTML5 6. Multilingual capabilities  7. Built- In Web Services - HAL, HTTP Basic Authentication , RESTful Web Services, Serialization 8. Fun & Fast Theming - Symfony2 and Twig-Template Engine 9.Industry Standard Approach   10. Strong accessib...

Major difference between drupal-6 and drupal 7

Entities:  The major difference in drupal 6 and drupal 7 is the introduction of   entities . I personally feel that introduction of entity in drupal 7, is something which changes the drupal from just CMS to CMF(content management framework). Here you can create your own entity and you will decide which fields you want to use (ex, author, last updated etc). Through entities you can straight forward use drupal as Framework and do what ever you want. In drupal 7, new concept of   entity   introduce.   Entity   is generic concept which may be node, user profile, comment, taxonomy-term In drupal 7, user reference and node reference is replaced by enitity reference . In drupal 7, CCK is now core module In drupal 7, coding section drupal 7 use PDO . In drupal 7, there is db_result function. In drupal 7, we use ajax for making page dynamic instead using ahah. Drupal 7 use the Storage engine InnoDB whereas D6 uses MyISAM.   What is New in Drupal...

Create a custom Drupal 8 module

Image
Tasks Completed Create a site localhost site with Drupal 8 with given tasks http://localhost/drupal8/ userid/password : admin/admin@123 Task 1 created a custom module called custom. * Implemented hook_form_FORM-ID_alter, This function will Add a New field in Site information page * Site Api key value stores in /custom/custom/config/install/custom.settings.yml file for demo, check below URL http://localhost/drupal8/admin/config/system/site-information Task 2 created a new menu as /nodecheck/{key}/{nid} to return json object * created a controller to match siteapikey and nodeid , * if Key doesn't match it will respond access denaid * if key matches but node id is wrong, it will respond as 'not a node' * if key and node both matches, it will respond json object for url demo, check below URL http://localhost/drupal8/nodecheck/testkey/1 Conclusion Refered drupal.org and stackoverflow.com Spended 3.5 hours to complete these tasks Background Information Wh...