Monday, August 16, 2021

Webform Contact/Phone Number Allowed only numbers not text with below jquery code

 

Using the below code, the text field can be changed to allow only the numbers, use can't enter text only numbers will be allowed.

------------------------------------------------------------------

jQuery( document ).ready(function() {

  jQuery("#field-id-or-class").attr('onkeypress','return isNumberKey(event);');

});

function isNumberKey(evt)

{

  var charCode = (evt.which) ? evt.which : event.keyCode;

 console.log(charCode);

    if (charCode != 46 && charCode != 45 && charCode > 31

    && (charCode < 48 || charCode > 57))

     return false;


  return true;

}

After Web Form Summited Zip file auto download


jQUERY CODE

-------------------------

 jQuery(function() {

jQuery('a[data-auto-download]').each(function(){

var $this = jQuery(this);

setTimeout(function() {

window.location = $this.attr('href');

}, 2000);

});

});

The below HTML code should be placed in the place of success message to make the zip file auto downlaod. 

HTML CODE:

------------------------------

<a class="button" data-auto-download="" href="/download.zip">click here</a>

Friday, January 22, 2021

Disabling a Module via the Database in Drupal 8

 

1) In D7 you could do this in the systems table by setting the status to 0. In D8, however this is stored in the config table. You can edit the blob value in the data field for this result:

SELECT * FROM config WHERE name like '%.extension%';


2) Or here's the fast (but dirty) solution:

- Delete the module's folder from the file system (/modules/

- truncate table cache_config using below commands 

 ---------------------------------------------------------------------


TRUNCATE cache_config;

TRUNCATE cache_container;

TRUNCATE cache_data;

TRUNCATE cache_default;

TRUNCATE cache_discovery;

TRUNCATE cache_dynamic_page_cache;

TRUNCATE cache_entity;

TRUNCATE cache_menu;

TRUNCATE cache_render;

TRUNCATE cache_toolbar;

Tuesday, September 1, 2020

WordPress - Disable Lost your password Link and Page Code

 // Disable Lost your password Link and Page

function remove_lostpassword_text ( $text ) {

         if ($text == 'Lost your password?'){$text = '';}

                return $text;

         }

add_filter( 'gettext', 'remove_lostpassword_text' );


add_action('init','possibly_redirect'); 

function possibly_redirect(){ 

   if (isset( $_GET['action'] )){  

     if ( in_array( $_GET['action'], array('lostpassword', 'retrievepassword') ) ) {

        wp_redirect( '/wp-login.php' ); exit;

     }

  }

}


Thursday, August 9, 2018

Drupal Menu not Saving Due to max_input_vars

Add below line to the php.ini or .user.ini which is located in site root folder, if this file is not available you care create and add this line and upload it to the server.
------------------------------------------
max_input_vars = 2000
------------------------------------------

OR

Add these lines to your .htaccess file:
php_value post_max_size = 20000M
php_value upload_max_filesize = 20000M
php_value max_execution_time = 30000
php_value max_input_time = 60000
php_value memory_limit = 8000M
php_value max_input_vars = 8000
php_value suhosin.post.max_vars = 8000
php_value suhosin.request.max_vars = 8000

Tuesday, June 19, 2018

Drupal special characters showing like & and   etc... in drupal page title. Code for fix

Replace below code in page.tpl:
<?php print html_entity_decode($head_title) ?>
instead of
<?php //print $title; ?>

Wednesday, November 8, 2017

Youtube Video Link directly to particular time


Here is the Youtube Video Link directly to particular time link code.

https://www.youtube.com/watch?v=whGwm0Lky2s&feature=youtu.be&t=14m11s

Thursday, April 20, 2017

How to add drupal block into a node?

<?php
     $block = module_invoke('block_name', 'block_view', 'block_id');
     print render($block['content']);
 ?>

Wednesday, July 13, 2016

Countdown Timer / Days count in Business days code in PHP

<?php
$start = new DateTime(null, new DateTimeZone('America/New_York'));
$end = new DateTime('2017-05-05');
// otherwise the  end date is excluded (bug?)
$end->modify('+1 day');

$interval = $end->diff($start);

// total days
$days = $interval->days;

// create an iterateable period of date (P1D equates to 1 day)
$period = new DatePeriod($start, new DateInterval('P1D'), $end);

// best stored as array, so you can add more than one
//$holidays = array('2012-09-07');

foreach($period as $dt) {
    $curr = $dt->format('D');

    // for the updated question
   // if (in_array($dt->format('Y-m-d'), $holidays)) {
     //  $days--;
   // }

    // substract if Saturday or Sunday
    if ($curr == 'Sat' || $curr == 'Sun') {
        $days--;
    }
}


echo $days; // 4?>

Sunday, March 13, 2016

The Future of Angular - Write Code. Learn Angular.

The  Angular is the most important in future for any web applications, it has more features and easy to implement what you want. In the future the trend of web desing is going off and using the latest platform  like bootstrap and Angular Js. these are most important in present trend.

There are lot of predefined codes are available to just do plug and play. So better to focus on latest frameworks and learn and use them on your works for better quality output.

Here are few website to follow:
http://www.learn-angular.org/
https://thinkster.io/a-better-way-to-learn-angularjs
https://www.codecademy.com/learn/learn-angularjs
http://www.w3schools.com/angular/


Monday, February 29, 2016

RGB to CMYK: how to prepare photos for print in Photoshop

In this photo editing tutorial we show you how to convert images from RGB to CMYK in Photoshop to produce perfect colour prints.
RGB to CMYK: how to prepare photos for print in Photoshop
After processing a photo to look good on screen, you may end up with a print that suffers from shifts in colour. The discrepancy between the screen and print colour is caused by a variety of factors.
Your computer’s screen produces millions of colours by mixing reds, greens and blues (RGB) together, while most domestic printers combine cyan, magenta, black and yellow (CMYK) inks to create a narrower range of colours. Colours that can’t be printed are referred to as ‘out-of-gamut’ colours.
In this tutorial we’ll demonstrate how to prepare a picture for print and avoid colour-related disappointments. By default, Photoshop uses the screen-friendly colour space called sRGB (standard RGB).
You can change this colour space to a narrower, more printable one called Adobe RGB (1998) that helps you reduce the number of out-of-gamut colours. There’s also a handy gamut warning that you can summon to identify unprintable colours.
We’ll show you how to set up Photoshop’s colour management tools so that you can convert files that have an unprintable sRGB colour space to the printer-compatible Adobe RGB (1998) colour space.
We’ll also demonstrate how to change Photoshop’s colour mode so it’s compatible with the printer’s CMYK ink-mixing technique, so that your images have a vibrant, printable range of colours.

How to convert photos from RGB to CMYK

How to convert photos from RGB to CMYK: step 1
01 Manage your colours
Go to Edit > Color Settings. In the Color Settings window, choose an appropriate location-based profile such as Europe Prepress 3. This will ensure Photoshop uses a print-friendly colour space called Adobe RGB (1998) instead of the default sRGB one. Leave the Profile Mismatch boxes ticked.
How to convert photos from RGB to CMYK: step 2
02 Convert the embedded profile
Download our start file and follow along! Open print_start.jpg. The embedded colour profile of this image describes its colours using the screen-friendly sRGB colour space. You can change the sRGB profile to a printer-compatible one by ticking the ‘Convert document’s colors to the working space’ button. Click OK to close the dialog box.
How to convert photos from RGB to CMYK: step 3
03 Gamut warning
To discover remaining unprintable colours, choose View > Gamut Warning. Problematic colours will appear as patches of grey. You could use a Vibrance adjustment layer to reduce the saturation of the colours. The gamut warning patches would vanish, but other colours may look a bit drab.
How to convert photos from RGB to CMYK: step 4
04 Change the mode
Go to Mode and choose CMYK Color. Click OK. This forces the colours into a print-compatible CMYK colour space. The gamut warning patches will vanish. Choose Mode > RGB Color. You can now use a Vibrance adjustment layer to boost the saturation without producing warnings.

Wednesday, February 24, 2016

jQuery to match an input field value against a pre-defined value on focusout | Drupal Den

Here is how to show a message on a form when the input field loses focus and it matches a predefined value. In this example a message appears if the user enters an email address that matches the domain of a free email provider, eg. Hotmail, Yahoo & Gmail.
NOTE: this doesn't validate and stop the user from being able to submit the form, it's just a message that appears. If you use the Webform module and want to prevent a user from submitting a form you can do this by also enabling the Webform Validation module and adding a Form Validation Rule of the type Words Blacklist.
Anyway back to creating a jQuery message which appears when a form input value matches a predefined value...
The below script checks for a match when the field loses focus - in this instance it's checking for '@hotmail.', '@yahoo.' & '@gmail.'. It was done in this way so that it matches for both '@yahoo.com' and '@yahoo.co.uk', and isn't case sensitive. You can build quite complex rules for matching using JavaScript regular expressions (RegEx).
The message is inserted directly after the email input field, and is removed once the match isn't found anymore.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<form>
    <input class="form-email" type="email" id="edit-submitted-email-address" name="submitted[email_address]" size="60">
</form>
 
<script>
(function ($) {     
    $('input.form-email').focusout(function(){
        var match = $(this).val().match(/@hotmail\.|@yahoo\.|@gmail\./gi);
        if(match){
                $(this).not('.emailAlertActive').after( '<p class="emailAlert">Please use your business email address.</p>' ).addClass('emailAlertActive');
        } else {
            $(this).siblings('.emailAlert').remove();
            $(this).removeClass('emailAlertActive')
        }
    })})(jQuery);
</script>