Skip to main content

Posts

Showing posts from March, 2016

Connecting to Multiple Databases Within Drupal

In the settings.php file, $databases is an array composed of multiple database connection strings. Here’s the default syntax, specifying a single connection: array(   'driver' => 'mysql',   'database' => 'databasename',   'username' => 'username',   'password' => 'password',   'host' => 'localhost',   'port' => 3306,   'prefix' => 'myprefix_', ); As an example, you might have two databases, the default database (in this case named D7) and a legacy database as defined here. $databases = array (   'default' =>   array (     'default' =>     array (       'driver' => 'mysql',       'database' => 'd7',       'username' => 'username',       'password' => 'userpassword',       'host' => 'localhost',       'port' => ...

Composer Manager for Drupal 8

Plz see  https://www.drupal.org/node/2405811 If following error eccur when we use "composer drupal-update" command. then show below link for patch. Update $packageToCleanup, 'tests' cleanup are no longer required for Behat/Mink package diff --git a/core/lib/Drupal/Core/Composer/Composer.php b/core/lib/Drupal/Core/Composer/Composer.php index 0d5b6aa..831346b 100644 --- a/core/lib/Drupal/Core/Composer/Composer.php +++ b/core/lib/Drupal/Core/Composer/Composer.php @@ -20,7 +20,7 @@ class Composer { protected static $packageToCleanup = [ - 'behat/mink' => ['tests', 'driver-testsuite'], + 'behat/mink' => ['driver-testsuite'], 'behat/mink-browserkit-driver' => ['tests'], 'behat/mink-goutte-driver' => ['tests'], 'doctrine/cache' => ['tests'], https://www.drupal.org/node/2682003

Key/Value Attributes of Hook_menu()

How to menu system works in drupal7?

Overview of the menu dispatching process Overview of the router and link building process

How to caching system work in Drupal?

There seems to be a lot of misunderstanding how Drupal caching works. I'm not talking about advanced caching mechanisms like Varnish, APC or memcache here, I'm talking about the core Drupal caching: page cache and block cache which are available in Drupal 7 core. Drupal 6 is similar but works a but differently because page caching was simplified for Drupal 7 (e.g. aggresive mode is now a available as a settings.php var) and the entire system also has become pluggable. Everybody knows this screen and the settings. But what do they exactly mean? What difference do they actually make? What do they do? Here is an attempt to explain the settings at '/admin/config/development/performance'. Page caching: If enables, page caching will only be used for anonymous users. If you enable page caching, the entire HTML of each page will be stored in the database. This significantly reduces the amount of queries needed. This automatically means that blocks will also get cache...

Write JS

(function ($) {   $( document ).ready(function() {     $('.popup-msg').hide();     $('.user-login-for-popup').hide();     $('.commerce-add-to-cart .form-submit').click(function(event){       var $uid = $('.user-login-for-popup').html();       if(!$uid) {         event.preventDefault();         $('.popup-msg').dialog({           maxWidth:600,           maxHeight: 250,           width: 600,           height: 250,           resizable: false,           modal: true,           title: 'You need to login or register to Leaps.',         });       }     });   }); })(jQuery);

How to import node form csv file in drupal7?

Here, I want to import user from csv file in drupal 7 site. Let's create a custom module and name the module as "csv_import". csv_import.info      name = Csv Import    description = Import node from csv file.    core = 7.x    package = Hsk csv_import.module <?php /**  * Implements hook_permission()  */ function csv_import_permission() {   return array(     'administer uploader' => array(       'title' => t('Administer Uploader'),       'description' => t('Allow the following roles to upload csv files to the server.'),     ),   ); } /**  * Implements hook_menu()  */ function csv_import_menu() {   $items['file-uploader'] = array(     'title' => 'Upload a File',     'type' => MENU_CALLBACK,     'description' => 'Import a csv',     'page callback' => 'drupal_get_fo...

How to make own "Condition" and "Action" in rule?

Drupal rules module provide by default events,conditions and action. But we want to create a custom components for additional functionality. Here I will tell you how to create Condition and Action . Let's create a custom module and name the module as "hsk_rule". hsk_rule.info      name = Hsk Rule    description = Hsk Custom Rules    core = 7.x    package = Hsk hsk_rule.module <?php /**  * implementation of hook_rules_condition_info()  */ function hsk_rule_rules_condition_info() {   return array(     'hsk_rule_condition_competition_start_type' => array(       'label' => t('Custom condition for node publish'),       'group' => 'Custom Condition in Rule' ,       'module' => 'hsk_rule',     ),   ); } /**  * Condition competition_start_condition_competition_start_type  */ function hsk_rule_condition_compet...