Skip to main content

Posts

Showing posts from 2015

How to Write Drupal Dynamic query with datbase SCHEMA in Postgres

<?php   $tbl = 'secc_rural';//schema name   $house_hold_id = '123456';   $query = db_select($tbl.".individual_21", "n");   $query->fields('n',array('name','ahl_tin','ahl_tin','fathername','name_sl','mothername','occupation','yob','hof','genderid','relation','house_hold_id'));     $query->condition('n.house_hold_id',db_like($house_hold_id) . '%', 'LIKE');   $query = $query->extend('TableSort')->extend('PagerDefault')->limit(20);   $result = $query->execute();

taxonomy in drupal custom form

To add taxonomy in drupal custom form. By using taxonomy_form() we can form a texonomy in form. For Ex: $vid=4; $category1 = taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy'); $form['taxonomy_info']['taxonomy1'] = array( '#type' => 'select', '#title' => t('Terms for the Website'), '#options' => $category1, '#description' => t('Website category'), );

mamchache drupal

Following steps are allowed to install memcache in drupal  7 1.Install the memcached binaries on your server. See How to install Memcache on Debian Etch[ http://www.lullabot.com/articles/how_install_memcache_debian_etch  ] or How to install Memcache on OSX [ http://www.lullabot.com/articles/setup-memcached-mamp-sandbox-environmen...  ] 2.Install the PECL memcache extension for PHP. 3. In settings.php add ini_set('memcache.hash_strategy','consistent');4. Put your site into offline mode.5. Download and install the memcache module [  http://drupal.org/project/memcache  ]6. If you have previously been running the memcache module, run update.php.7. Apply the DRUPAL-5-cache-serialize.patch that comes with memcache module [memcache/patches]I applied DRUPAL-5-3-cache-serialize.patch hence I am using drupal 5.38. Start at least one instance of memcache on the server.[ex ./memcached -d -m 2048 -l 10.0.0.40 -p 11211 ]Here 11211 is an instance of memcache, 10....

How to implement Verhoeff’s algorithms In PHP with Postgres

Create new function in postgres db , like, calculateVerhoeff() returns an integer single digit which is the checksum to be used -- verifyVerhoeff() returns a boolean, true for number is valid, false for invalid CREATE OR REPLACE FUNCTION checksumVerhoeff ( num numeric , calcChecksum boolean ) RETURNS integer LANGUAGE plpgsql AS $$ DECLARE d CHAR ( 100 ) : = '0123456789123406789523401789563401289567401239567859876043216598710432765982104387659321049876543210' ; p CHAR ( 80 ) : = '01234567891576283094580379614289160435279453126870428657390127938064157046913258' ; inv CHAR ( 10 ) : = '0432156789' ; c integer : = 0 ; len integer ; m integer ; i integer : = 0 ; n VARCHAR ( 255 ); BEGIN /* Start Processing */ n : = REVERSE ( num :: varchar ); len : = LENGTH ( n ); WHILE ( i < len ) LOOP IF ca...

How to create user and send mail by custom code drupal 7

$mail = 'dharmendrait08@gmail.com'; $phone = '8568077276'; $name = 'teste_user';   //set up the user fields   $fields = array(     'name' => $name,     'mail' => $mail,     'pass' => $phone,     'status' => 1,     'init' => $mail,     'roles' => array(       DRUPAL_AUTHENTICATED_RID => 'artist',     ),   );   $account = user_save('', $fields);   $account = user_load($account->uid);   $account->password = $fields['pass'];   $account->field_phone['und'][0]['value'] = $phone;   $account->field_name['und'][0]['value'] = $name;   $account->field_user_type['und'][0]['value'] = 'Artist';       $op = 'register_no_approval_required';   $data = _user_mail_notify($op, $account);

Dynamic query in drupal 7

Today i am demonstrating how to write dynamic query in drupal 7, $query  =  db_select('node','n')                  ->fields('n',array('title','nid'))                  ->condition('n.status',1)                  ->execute(); It simply returns the object of the current query, foreach($query as $result){     echo $result->title; } How To Use database function in dynamic query  $tbl = 'secc_rural';  $house_hold_id = '09280030005';   $query = db_select($tbl.".individual_21", "n");   $query->fields('n',array('name','ahl_tin','ahl_tin','fathername','name_sl','mothername','occupation','yob','hof','genderid','relation','house_hold_id'));   //$query->addExpression('substr(house_hold_id,1,11)',$house_hold_id);   $query->where('substr(house_hold_id,1,11) = :h...

How to integrate apache solar search integration..

http://www.slideshare.net/reallyordinary/intro-to-apache-solr-for-drupal-8157887?related=1 I am setting the solr with lando dev tool: 1 - setup the sole server & other settings in lando.yml file like this, services:   phpma:     type: phpmyadmin   search:     type: solr:8     core: drupal8     portforward: 8983     config:       dir: config/solr-conf/8.x proxy:   phpma:     - phpma.panth-rare.lndo.site   solr:     - solr.panth-rare.lando.site:8983 After it, run lando rebuild & lando start Now your solr server is ready, enable the search_api_solr module, and add the solr server, Full Documentation how to install & configure the solr on drupal 8 with Lando https://opensenselabs.com/blog/tech/use-apache-solr-drupal-8 After a successful server setup, download the config.zip file & put it config/solr-conf/8.x,   where config is the ...

How to user Despite vs In spite of

by the way both of them , in spite of and despite are synonyms Hindi meanig is " के बावजूद " Despite means "even though,"  => भले ही "notwithstanding," => होते हुए भी, हालांकि or "regardless of." It’s the opposite of "because of/due to," and can be used with a noun or gerund.

What is github and how to use it

Github is a plateform to share code with friends, colleagues or any unknows persons. it's also used to keep backup of our code. github is actually two types free and paid, if you want to keep our code privately then you need to pay , for free account the code will be public anyone can see it and can download the code. How to start using GitHub for Linux   First thing first, you need to have the GitHub account if not then register yourself on Github ( https://github.com/ ). commands for GitHub to create, update and download the repository 1- first install git on our Linux system if you don't have. sudo apt-get install git Configure git directory and pull the code from Github  navigate to the working directory like cd /var/www/html/drupal-8 Run these below commands to initialize the git & configure it. git init git config --global user.name "raj" (here raj is my username) git config --global user.email "dharmendrait08@gmai...