49+
votes
3610 views

This error occurs usually during a file upload and when you try to check the Drupal logs you will find error something like this -
"PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 2: INSERT INTO {file_managed}."

Usually if you remove the white spaces from your filename which you are uploading will solve this error . So for example if you have a filename like "tech rappers.jpg" then try changing the filename to "techrappers.jpg" or...

Read More
15+
votes
1368 views

For Drupal 7 :

drush vset maintenance_mode 1  // To take website into maintenance mode
drush vset maintenance_mode 0  // To take website into live mode

For Drupal 6 :

drush vset site_offline 1  // To take website into maintenance mode
drush vset site_offline 0  // To take website into live mode
25+
votes
1324 views

In this example you can line up 3 divs in the same line

HTML :

<div class="main-class">
    <div class="sub-class">C1</div>
    <div class="sub-class">C2</div>
    <div class="sub-class">C3</div>
</div>

CSS:

.main-class
{
    display: table;
    width: 100%; /*Optional*/
    table-layout: fixed; /*Optional...
Read More
52+
votes
1458 views

By using a div with style z-index:1; and position: absolute; you can overlay your div on any other div.

z-index determines the order in which divs 'stack'. A div with a higher z-index will appear in front of a div with a lower z-index. Note that this property only works with positioned elements.

53+
votes
1170 views

To make a certain part clickable and then hide it when you click anywhere else, you need to check if your click place has certain class then show it otherwise hide it.
So we will check our click on whole document and then we will see if it has certain class attached to it or not. Like this :

(function ($) { 
// Check the click on whole DOM
$(document).on('click', function(e) {
       // Check if target has certain class
        if($(e.target).hasClass('...
Read More
41+
votes
1927 views

To resolve this error you must wrap your JavaScript inside function like this :

(function ($) { 
  // Your jQuery code.
  $('#something1').click(function () {
    $('#something2').slideToggle();
  });
  //Put your code between these comments.
})(jQuery);
52+
votes
2017 views

By default drupal date module stores all the values in the UTC format and to change it into the current local time format you can do something suggested in this post for the conversion :

http://techrappers.com/post/69/how-convert-utc-dates-local-time-php

The above post will give you exact local time after conversion which can be used in sql query for comparison.

33+
votes
1875 views

Get the value of UTC time and convert it into unix timestamp and then convert that timestamp to date will give you exact local date and time.

$time = strtotime($dateInUTC.' UTC');
$LocalDate = date("Y-m-d H:i:s", $time);
40+
votes
2772 views

Nice Menu module of drupal by default provide hover support of mouse. This tutorial will show you how to add an on-click event support for nice menus.
This post also solves the issue listed over here https://www.drupal.org/node/352711

1) Override the default superfish.js provided with the nice menus module. Nice menus superfish javascript provide the on-hover support but you have to override with the new superfish.js which provide...

Read More
29+
votes
2442 views

To display the row number generally we can use the views "Global: View result counter (ID)" field in the view but if your view is grouped by
any specific field then it will start displaying the wrong row number. It will show the on the basis of the latest uploaded content.
You can correct this by using PHP and its quite straight forward.
For this you have to create a template inside your theme/templates folders.

1) Name the template
Go to your view ->...

Read More