Friday, February 23, 2018

Drupal 8 - Simplelogin - Customize Drupal Login, Password and Register pages with Background images

It is a simple module for Customize Drupal Login, Password and Register pages with Background images.
Administrators can provide the ability to allow users to attach their own background images/ own background color to user login, password, registration pages. Better features including customize background color, image settings.

URL: https://www.drupal.org/project/simplelogin
Features:
  • Clean & Sleek Design,
  • Customize background color, link color, submit button color,
  • Customize image settings,
  • Background image Opacity,
  • Remove unwanted Css files from simplelogin pages,
  • Login pages wrapper width,
  • Mobile responsive,

Simplelogin

Friday, June 2, 2017

Best Useful Modules on Drupal 8

Admin Toolbar - Admin Toolbar intends to improve the default Drupal Toolbar (the administration menu at the top of your site) to transform it into a drop-down menu, providing a fast access to all administration pages. (or The Coffee module helps you to navigate through the Drupal admin faster)

Webform - Webform is the module for making forms and surveys in Drupal. After a submission customizable e-mails can be sent to administrators and/or submitters. Results can be exported into Excel or other spreadsheet applications. Webform also provides some basic statistical review and has an extensive API for expanding its features.

Blog - This blog module is the same included with Drupal core before version 8. It was removed from Drupal core

Paragraphs - Paragraphs is the new way of content creation!
It allows you — Site Builders — to make things cleaner so that you can give more editing power to your end-users.

Pathauto -The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias.

Simple XML sitemap - Every webpage needs an automatic XML sitemap generator for SEO reasons. This module aims to be a replacement for the xmlsitemap module for Drupal 8. Simple xml sitemap is lighter than xmlsitemap in terms of resources and usability.

reCAPTCHA - Uses the Google reCAPTCHA web service to improve the CAPTCHA system. It is tough on bots and easy on humans. reCAPTCHA is built for security. Armed with state of the art technology, it always stays at the forefront of spam and abuse fighting trends. reCAPTCHA is on guard for you, so you can rest easy.

Search API - This module provides a framework for easily creating searches on any entity known to Drupal, using any kind of search engine. For site administrators, it is a great alternative to other search solutions, since it already incorporates facetting support and the ability to use the Views module for displaying search results, filters, etc.

Features - The features module enables the capture and management of features in Drupal. A feature is a collection of Drupal entities which taken together satisfy a certain use-case.

dropzonejs - Drupal integration for DropzoneJS - an open source library that provides drag’n’drop file uploads with image previews.

Slick Carousel - Slick is a powerful and performant slideshow/carousel solution leveraging Ken Wheeler's Slick carousel. (Slick Views - Provides Views style plugin, Slick Media - Provides integration between Slick carousel, Media Entity, and Video Embed Media)

REST UI - A user interface for configuring Drupal 8's REST module.

Google Analytics - This simple module allows site admins the ability to easily configure Google Analytics in Drupal.

view_unpublished - This module allows you to grant access for specific user roles to view unpublished nodes of a specific type. Access control is quite granular in this regard.

Image Source: https://pixabay.com

Wednesday, February 22, 2017

Drupal 8 .info.yml

Drupal 8 uses to handle routing, sessions and the services container, amongst other things, is borrowed from Symfony 2 File Name: sixbones.info.yml




name: Six Bones
description: Custom Module
package: Custom

type: module
core: 8.x
       
 

Tuesday, April 5, 2016

Drupal 7 Add Custom Content Type Body Field


<?php
node_types_rebuild();
$types = node_type_get_types();
node_add_body_field($types['content_type_name']);
?>

Use: php filter and run this code or use devel/php

Friday, February 26, 2016

Install PHP SOAP on CentOS 7 in PHP 7

Install "php-soap":
============
sudo yum install php70w-soap

Terminal:
=======
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.digistar.vn
 * epel: epel.mirror.srv.co.ge
 * extras: centos-hn.viettelidc.com.vn
 * nux-dextop: mirror.li.nux.ro
 * updates: mirror.digistar.vn
 * webtatic: sp.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package php70w-soap.x86_64 0:7.0.3-1.w7 will be installed
--> Processing Dependency: php70w-common(x86-64) = 7.0.3-1.w7 for package: php70w-soap-7.0.3-1.w7.x86_64
--> Running transaction check
---> Package php70w-common.x86_64 0:7.0.2-1.w7 will be updated
--> Processing Dependency: php70w-common(x86-64) = 7.0.2-1.w7 for package: php70w-gd-7.0.2-1.w7.x86_64
--> Processing Dependency: php70w-common(x86-64) = 7.0.2-1.w7 for package: php70w-process-7.0.2-1.w7.x86_64
--> Processing Dependency: php70w-common(x86-64) = 7.0.2-1.w7 for package: php70w-opcache-7.0.2-1.w7.x86_64
--> Processing Dependency: php70w-common(x86-64) = 7.0.2-1.w7 for package: php70w-tidy-7.0.2-1.w7.x86_64
--> Processing Dependency: php70w-common(x86-64) = 7.0.2-1.w7 for package: php70w-pdo-7.0.2-1.w7.x86_64
--> Processing Dependency: php70w-common(x86-64) = 7.0.2-1.w7 for package: php70w-bcmath-7.0.2-1.w7.x86_64
--> Processing Dependency: php70w-common(x86-64) = 7.0.2-1.w7 for package: php70w-xml-7.0.2-1.w7.x86_64
--> Processing Dependency: php70w-common(x86-64) = 7.0.2-1.w7 for package: php70w-mbstring-7.0.2-1.w7.x86_64
--> Processing Dependency: php70w-common(x86-64) = 7.0.2-1.w7 for package: php70w-7.0.2-1.w7.x86_64
--> Processing Dependency: php70w-common(x86-64) = 7.0.2-1.w7 for package: php70w-cli-7.0.2-1.w7.x86_64
---> Package php70w-common.x86_64 0:7.0.3-1.w7 will be an update
--> Running transaction check
---> Package php70w.x86_64 0:7.0.2-1.w7 will be updated
---> Package php70w.x86_64 0:7.0.3-1.w7 will be an update
---> Package php70w-bcmath.x86_64 0:7.0.2-1.w7 will be updated
---> Package php70w-bcmath.x86_64 0:7.0.3-1.w7 will be an update
---> Package php70w-cli.x86_64 0:7.0.2-1.w7 will be updated
---> Package php70w-cli.x86_64 0:7.0.3-1.w7 will be an update
---> Package php70w-gd.x86_64 0:7.0.2-1.w7 will be updated
---> Package php70w-gd.x86_64 0:7.0.3-1.w7 will be an update
---> Package php70w-mbstring.x86_64 0:7.0.2-1.w7 will be updated
---> Package php70w-mbstring.x86_64 0:7.0.3-1.w7 will be an update
---> Package php70w-opcache.x86_64 0:7.0.2-1.w7 will be updated
---> Package php70w-opcache.x86_64 0:7.0.3-1.w7 will be an update
---> Package php70w-pdo.x86_64 0:7.0.2-1.w7 will be updated
---> Package php70w-pdo.x86_64 0:7.0.3-1.w7 will be an update
---> Package php70w-process.x86_64 0:7.0.2-1.w7 will be updated
---> Package php70w-process.x86_64 0:7.0.3-1.w7 will be an update
---> Package php70w-tidy.x86_64 0:7.0.2-1.w7 will be updated
---> Package php70w-tidy.x86_64 0:7.0.3-1.w7 will be an update
---> Package php70w-xml.x86_64 0:7.0.2-1.w7 will be updated
---> Package php70w-xml.x86_64 0:7.0.3-1.w7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                Arch          Version             Repository       Size
================================================================================
Installing:
 php70w-soap            x86_64        7.0.3-1.w7          webtatic        172 k
Updating for dependencies:
 php70w                 x86_64        7.0.3-1.w7          webtatic        2.8 M
 php70w-bcmath          x86_64        7.0.3-1.w7          webtatic         35 k
 php70w-cli             x86_64        7.0.3-1.w7          webtatic        2.8 M
 php70w-common          x86_64        7.0.3-1.w7          webtatic        1.2 M
 php70w-gd              x86_64        7.0.3-1.w7          webtatic        135 k
 php70w-mbstring        x86_64        7.0.3-1.w7          webtatic        540 k
 php70w-opcache         x86_64        7.0.3-1.w7          webtatic        122 k
 php70w-pdo             x86_64        7.0.3-1.w7          webtatic         89 k
 php70w-process         x86_64        7.0.3-1.w7          webtatic         40 k
 php70w-tidy            x86_64        7.0.3-1.w7          webtatic         29 k
 php70w-xml             x86_64        7.0.3-1.w7          webtatic        127 k

Transaction Summary
================================================================================
Install  1 Package
Upgrade             ( 11 Dependent packages)

Total download size: 8.1 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for webtatic
(1/12): php70w-bcmath-7.0.3-1.w7.x86_64.rpm                |  35 kB   00:00    
(2/12): php70w-gd-7.0.3-1.w7.x86_64.rpm                    | 135 kB   00:00    
(3/12): php70w-mbstring-7.0.3-1.w7.x86_64.rpm              | 540 kB   00:00    
(4/12): php70w-opcache-7.0.3-1.w7.x86_64.rpm               | 122 kB   00:00    
(5/12): php70w-pdo-7.0.3-1.w7.x86_64.rpm                   |  89 kB   00:00    
(6/12): php70w-process-7.0.3-1.w7.x86_64.rpm               |  40 kB   00:00    
(7/12): php70w-soap-7.0.3-1.w7.x86_64.rpm                  | 172 kB   00:00    
(8/12): php70w-tidy-7.0.3-1.w7.x86_64.rpm                  |  29 kB   00:00    
(9/12): php70w-7.0.3-1.w7.x86_64.rpm                       | 2.8 MB   00:01    
(10/12): php70w-xml-7.0.3-1.w7.x86_64.rpm                  | 127 kB   00:00    
(11/12): php70w-common-7.0.3-1.w7.x86_64.rpm               | 1.2 MB   00:04    
(12/12): php70w-cli-7.0.3-1.w7.x86_64.rpm                  | 2.8 MB   00:06    
--------------------------------------------------------------------------------
Total                                              1.3 MB/s | 8.1 MB  00:06    
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : php70w-common-7.0.3-1.w7.x86_64                             1/23
  Updating   : php70w-cli-7.0.3-1.w7.x86_64                                2/23
  Updating   : php70w-7.0.3-1.w7.x86_64                                    3/23
  Updating   : php70w-gd-7.0.3-1.w7.x86_64                                 4/23
  Updating   : php70w-process-7.0.3-1.w7.x86_64                            5/23
  Updating   : php70w-tidy-7.0.3-1.w7.x86_64                               6/23
  Updating   : php70w-opcache-7.0.3-1.w7.x86_64                            7/23
  Updating   : php70w-bcmath-7.0.3-1.w7.x86_64                             8/23
  Updating   : php70w-xml-7.0.3-1.w7.x86_64                                9/23
  Updating   : php70w-mbstring-7.0.3-1.w7.x86_64                          10/23
  Updating   : php70w-pdo-7.0.3-1.w7.x86_64                               11/23
  Installing : php70w-soap-7.0.3-1.w7.x86_64                              12/23
  Cleanup    : php70w-7.0.2-1.w7.x86_64                                   13/23
  Cleanup    : php70w-cli-7.0.2-1.w7.x86_64                               14/23
  Cleanup    : php70w-pdo-7.0.2-1.w7.x86_64                               15/23
  Cleanup    : php70w-mbstring-7.0.2-1.w7.x86_64                          16/23
  Cleanup    : php70w-xml-7.0.2-1.w7.x86_64                               17/23
  Cleanup    : php70w-bcmath-7.0.2-1.w7.x86_64                            18/23
  Cleanup    : php70w-opcache-7.0.2-1.w7.x86_64                           19/23
  Cleanup    : php70w-tidy-7.0.2-1.w7.x86_64                              20/23
  Cleanup    : php70w-process-7.0.2-1.w7.x86_64                           21/23
  Cleanup    : php70w-gd-7.0.2-1.w7.x86_64                                22/23
  Cleanup    : php70w-common-7.0.2-1.w7.x86_64                            23/23
  Verifying  : php70w-7.0.3-1.w7.x86_64                                    1/23
  Verifying  : php70w-gd-7.0.3-1.w7.x86_64                                 2/23
  Verifying  : php70w-cli-7.0.3-1.w7.x86_64                                3/23
  Verifying  : php70w-process-7.0.3-1.w7.x86_64                            4/23
  Verifying  : php70w-tidy-7.0.3-1.w7.x86_64                               5/23
  Verifying  : php70w-opcache-7.0.3-1.w7.x86_64                            6/23
  Verifying  : php70w-bcmath-7.0.3-1.w7.x86_64                             7/23
  Verifying  : php70w-xml-7.0.3-1.w7.x86_64                                8/23
  Verifying  : php70w-mbstring-7.0.3-1.w7.x86_64                           9/23
  Verifying  : php70w-common-7.0.3-1.w7.x86_64                            10/23
  Verifying  : php70w-pdo-7.0.3-1.w7.x86_64                               11/23
  Verifying  : php70w-soap-7.0.3-1.w7.x86_64                              12/23
  Verifying  : php70w-7.0.2-1.w7.x86_64                                   13/23
  Verifying  : php70w-bcmath-7.0.2-1.w7.x86_64                            14/23
  Verifying  : php70w-mbstring-7.0.2-1.w7.x86_64                          15/23
  Verifying  : php70w-xml-7.0.2-1.w7.x86_64                               16/23
  Verifying  : php70w-common-7.0.2-1.w7.x86_64                            17/23
  Verifying  : php70w-gd-7.0.2-1.w7.x86_64                                18/23
  Verifying  : php70w-pdo-7.0.2-1.w7.x86_64                               19/23
  Verifying  : php70w-cli-7.0.2-1.w7.x86_64                               20/23
  Verifying  : php70w-process-7.0.2-1.w7.x86_64                           21/23
  Verifying  : php70w-tidy-7.0.2-1.w7.x86_64                              22/23
  Verifying  : php70w-opcache-7.0.2-1.w7.x86_64                           23/23

Installed:
  php70w-soap.x86_64 0:7.0.3-1.w7                                              

Dependency Updated:
  php70w.x86_64 0:7.0.3-1.w7             php70w-bcmath.x86_64 0:7.0.3-1.w7     
  php70w-cli.x86_64 0:7.0.3-1.w7         php70w-common.x86_64 0:7.0.3-1.w7     
  php70w-gd.x86_64 0:7.0.3-1.w7          php70w-mbstring.x86_64 0:7.0.3-1.w7   
  php70w-opcache.x86_64 0:7.0.3-1.w7     php70w-pdo.x86_64 0:7.0.3-1.w7        
  php70w-process.x86_64 0:7.0.3-1.w7     php70w-tidy.x86_64 0:7.0.3-1.w7       
  php70w-xml.x86_64 0:7.0.3-1.w7       

Complete!

Restart Apache:
===========
systemctl restart httpd

Check if SOAP enabled or not:
=====================
php -m | grep -i soap
soap




Thursday, January 21, 2016

How to print drupal 7 breadcrumb in custom .tpl files?

Where-ever you can add it.
<?php print theme('breadcrumb', array('breadcrumb'=>drupal_get_breadcrumb())); ?>

Thursday, December 17, 2015

A simple multistep form with a Next and a Back button - Drupal


function hook_menu(){
    $items = array();
    $items['multistep'] = array(
    'title' => 'Multistep',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('multistep'),
    'access callback' => TRUE,
  );
    return $items;
}

//-------------------------------------- Form 1 ----------------------------------------------------

function multistep($form, &$form_state) {

  if (!empty($form_state['page_num']) && $form_state['page_num'] == 2) {
    return multistep_page_two($form, $form_state);
  }
  if (!empty($form_state['page_num']) && $form_state['page_num'] == 3) {
    return multistep_page_three($form, $form_state);
  }
 
  $form_state['page_num'] = 1; 

  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#size' => 20,
    '#maxlength' => 20,
    '#required' => TRUE,
    '#default_value' => !empty($form_state['values']['name']) ? $form_state['values']['name'] : '',
  );

  $form['next'] = array(
    '#type' => 'submit',
    '#value' => 'Next >>',
    '#submit' => array('multistep_next_submit'),
    '#validate' => array('multistep_next_validate'),
  );
  return $form;
}


//----------------------------------------- Form 2 -------------------------------------------------

function multistep_page_two($form, &$form_state) {

  $form['email'] = array(
    '#type' => 'textfield',
    '#title' => t('Email'),
    '#required' => TRUE,
    '#default_value' => !empty($form_state['values']['email']) ? $form_state['values']['email'] : '',
  );

  $form['back'] = array(
    '#type' => 'submit',
    '#value' => t('<< Back'),
    '#submit' => array('multistep_page_two_back'),
    '#limit_validation_errors' => array(),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Next >>'),
    '#submit' => array('multistep_page_two_submit'),
  );
  return $form;
}

//------------------------------------------ Form 3 ------------------------------------------------

function multistep_page_three($form, &$form_state) {
  $form['phone'] = array(
    '#type' => 'textfield',
    '#title' => t('Phone'),
    '#required' => TRUE,
    '#default_value' => !empty($form_state['values']['phone']) ? $form_state['values']['phone'] : '',
  );

  $form['back'] = array(
    '#type' => 'submit',
    '#value' => t('<< Back'),
    '#submit' => array('multistep_page_three_back'),
    '#limit_validation_errors' => array(),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
    '#submit' => array('multistep_page_three_submit'),
  );
  return $form;
}

//------------------------------------------ Validate -----------------------------------------------

function multistep_next_validate($form, &$form_state) {
    // validate code here...
}

//------------------------------------------- Back ---------------------------------------------------

function multistep_page_two_back($form, &$form_state) {
  $form_state['values'] = $form_state['page_values'][1];
  $form_state['page_num'] = 1;
  $form_state['rebuild'] = TRUE;
}

function multistep_page_three_back($form, &$form_state) {
  $form_state['values'] = $form_state['page_values'][2];
  $form_state['page_num'] = 2;
  $form_state['rebuild'] = TRUE;
}

//------------------------------------- Submit Handlers ------------------------------------

function multistep_next_submit($form, &$form_state) {
  $form_state['page_values'][1] = $form_state['values'];

  if (!empty($form_state['page_values'][2])) {
    $form_state['values'] = $form_state['page_values'][2];
  }
  $form_state['page_num'] = 2;
  $form_state['rebuild'] = TRUE;
}

function multistep_page_two_submit($form, &$form_state) {
  $form_state['page_values'][2] = $form_state['values'];

  if (!empty($form_state['page_values'][3])) {
    $form_state['values'] = $form_state['page_values'][3];
  }
  $form_state['page_num'] = 3;
  $form_state['rebuild'] = TRUE;
}

function multistep_page_three_submit($form, &$form_state) {
  $form_state['page_values'][3] = $form_state['values'];
  //dsm($form_state['page_values']);
  drupal_set_message(t('The form has been submitted.'));
}


For more information refer Drupal example module: form_example_tutorial_8

Tuesday, December 15, 2015

Add CSS files and JavaScript files at the bottom of a page in Drupal 7

template_preprocess_html() in template.php file. Preprocess variables for html.tpl.php

function themename_preprocess_html(&$variables) {

  // Add external file
  drupal_add_css('https://fonts.googleapis.com/css?family=Roboto:400,300,500,700',array('type' => 'external'));

  // Add Javascript file at the bottom of a page
  drupal_add_js('/sites/all/themes/purple/js/bootstrap.min.js', array('type' => 'file', 'scope' => 'footer', 'weight' => 10));

}

Wednesday, November 25, 2015

How to export with limit the number of records from mysqldump?

mysqldump --opt --where='1 limit 10' -h IP_ADDRESS -u USER_NAME DATABASE_NAME TABLE_NAME > databasetable.sql