How to add a block in Drupal and how to configuring a block in Drupal

Blocks are the boxes of content that can be displayed in regions (such as footer or sidebar) on your page. Depending on your themes regions you may have the ability to include blocks in your right, left, middle or any other configurable region of your theme. Many of the modules like ecommerce, polls come with predefined blocks that you can place in any region of your theme. You can create your own custom blocks with any html editor and place these contents in a block. Each custom block has a title, a description, and a body.

Blocks are configured per theme.If you change the theme or enable multiple themes, you will need to configure blocks per theme. Blocks can be enabled or disabled by clicking on Administration > Site Building > Blocks.

Adding a new block in Drupal : 
1. From the Blocks overview page (Administration > Site Building > Blocks), click the “Add Block” tab.
2. Insert a Block description (*required), which will be displayed on the block overview page.
3. Insert a Title for the block.
4. Insert the body content for the block. Be sure to confirm you are using the correct input format for your block.
5. (optional) Set User, Role, and Page specific visibility settings.
6. When you click save, the block is created but not placed in a region by default. You will need to drag and drop it into a region in order for it to show up on the site.

Configuring a block in Drupal :
1. Go to the Blocks overview page (Administration > Site Building > Blocks) to configure the blocks on your site.
2. This page allows you to drag-and-drop blocks into different regions as well as reorder the blocks within a region.
3. Next to each block you can click “Configure” to change the specific block settings:
            * Block title: Allows you to override the default title for the block
            * User, Role, and Page specific visibility: Adjust visibility for block based on user, role or page.
            * Additional settings may also be available, depending on the particular block.

Reference : http://drupal.org/getting-started/6/admin/build/block

Syntax Highlighting in Drupal WordPress post and comments

If you want to highlight the code/syntax when making yor comments/post in Drupal and WordPress, just wrap it with the following tag.
[sourcecode language=php]
// Your Code Here
[/sourcecode]

The above piece of code will be highlighted with PHP code format.

The language parameter controls how the code is syntax highlighted. The following languages are supported:
- actionscript3
- bash
- coldfusion
- cpp
- csharp
- css
- delphi
- erlang
- fsharp
- diff
- groovy
- html
- javascript
- java
- javafx
- matlab (keywords only)
- objc
- perl
- php
- text
- powershell
- python
- r
- ruby
- scala
- sql
- vb
- xml

Reference: WordPress.com – Posting Source Code

jQuery & Cookies – How to get/set/delete cookies in jQuery

To get/set/delete cookies in jQuery, for this you can use jQuery Cookie plugin

Here is how to use jQuery Cookie plugin in your code:

// Setting a cookie
$.cookie('myCookie':'myValue');

// Creating cookie with all availabl options
$.cookie('myCookie1', 'myValue1', { expires: 7, path: '/', 
domain: 'avinash6784.wordpress.com', secure: true });

// Get a cookie
$.cookie('myCookie');

// Delete a cookie
$.cookie('myCookie', null);

How to get tables statistics / tables status in MySQL

MySQL tables statistics / MySQL tables status 

To get the MySQL table status and to get more information about table (size, engine, no. of rows etc.), following is the very useful command.

SHOW TABLE STATUS [{FROM | IN} db_name] [LIKE 'pattern' | WHERE expr]
//If you have selected a database then run the following command:
SHOW TABLE STATUS LIKE '%'

MySQL returns information about all the tables in the selected database. For more info about what MySQL returns, http://dev.mysql.com/doc/refman/5.1/en/show-table-status.html.

If you want to see information about a particular table in a particular database then you run the command as follows:

SHOW TABLE STATUS FROM <database name> LIKE '<table name>'

Popular Drupal Modules / Popular Modules In Drupal

Drupal Modules
The most popular Drupal modules

Here you will find a list of the most popular Drupal modules, a short description of what they do, a download link plus how to install instructions.
Source Link : http://www.siteground.com/drupal_modules.htm

Add External Link To Menu In Drupal

Following are the steps to add an external link to menu in Drupal:

1. In the navigation menu click Administer -> Site Building -> Menus
2. Choose the menu you would like to add the external link to
3. At the top click Add Item
4. Under Path enter the url of the site you would like to link to.
5. Under Menu link title enter the name that is to be shown on the menu.
6. You may enter a description for the menu item
7. Choose it’s parent
8. Under weight you can set where the menu item will appear in the menu. A smaller number will make it appear higher than a bigger number.
9. Click Save

Drupal SEO (Search Engine Optimization) Modules

Drupal SEO (Search Engine Optimization) Modules

1. Path - Using Path module, you can set the path for an individual node with the Path module (on the node/add or node edit form) (For More Info http://drupal.org/documentation/modules/path)

2. Pathauto - The Pathauto module automatically generates path aliases for various kinds of content (nodes, categories, users) without requiring the user to manually specify the path alias (For More Info http://drupal.org/project/pathauto)

3. Nodewords/ Meta tags - This Module allows you to add meta tags to Drupal pages, both manually and automatically based on various settings.(For More Info http://drupal.org/project/nodewords)

4. Page Title - This module allows you to set patterns for your Drupal content types (pages, blog posts, stories, articles…). You can also create a unique title for your index page here. (For More Info http://drupal.org/project/page_title)

5. Global Redirect - GlobalRedirect is a simple module which checks the current URL for an alias and does a 301 redirect to it if it is not being used. GlobalRedirect checks the current URL for a trailing slash, removes it if present and repeats check 1 with the new request. GlobalRedirect checks if the current URL is the same as the site_frontpage and redirects to the frontpage if there is a match.(For More info http://drupal.org/project/globalredirect)

6. Path Redirect - This module allows you to specify a redirect from one path to another path or an external URL, using any HTTP redirect status. (For More Info http://drupal.org/project/path_redirect)

7. XML sitemap - The XML sitemap module creates an xml sitemap that you can submit to the search engines.(For Info http://drupal.org/project/xmlsitemap)

8. Service links - Service Links allow the users to submit the contents of your website on social bookmarking sites, blog search engines, social networks and similiar, either add them in the browser, without require external “resources” as other addons do. (For More Info http://drupal.org/project/service_links)

9. Google analytics - This Module Adds the Google Analytics web statistics tracking system to your website. (For More Info http://drupal.org/project/google_analytics)

10. Related Links - The related links module enables nodes to display related URLs to the user via blocks. (For More Info http://drupal.org/project/relatedlinks)

11. Search 404 - Instead of showing a standard “404 Page not found”, this module performs a search on the keywords in the URL.(For More Info http://drupal.org/project/search404)

12. Url list - Creates a list of node URLs at /q=urllist.txt or (/urllist.txt for clean URLs) for submitting to search engines (For More Info http://drupal.org/project/urllist)

13. SEO Checklist - This module provides a checklist of recommended Drupal modules and good Drupal SEO (Search Engine Optimization) best practices. (For More Info http://drupal.org/ project/seo_checklist)

JavaScript Password Generator

I have written a small piece of code to generate a random password in JavaScript. This function is very good JavaScript Password Generator tool.

JavaScript Password Generator

//JavaScript Password Generator
function generatePassword(passwordLength, specialChars) {
  var iteration = 0;
  var password = "";
  var randomNumber;
  if(specialChars == undefined){
      var specialChars = false;
  }
  while(iteration &lt; passwordLength){
    randomNumber = (Math.floor((Math.random() * 100)) % 94) + 33;
    if(!specialChars){
      if ((randomNumber &gt;=33) &amp;&amp; (randomNumber &lt;=47)) { continue; }
      if ((randomNumber &gt;=58) &amp;&amp; (randomNumber &lt;=64)) { continue; }
      if ((randomNumber &gt;=91) &amp;&amp; (randomNumber &lt;=96)) { continue; }
      if ((randomNumber &gt;=123) &amp;&amp; (randomNumber &lt;=126)) { continue; }
    }
    iteration++;
    password += String.fromCharCode(randomNumber);
  }
  return password;
}

This function takes two parameters: integer value for password length and optional boolean value true if you want to include special characters in your generated passwords.

How to Use :

generatePassword(8);
// Output : ZMfBhjhM

Core Modules In Drupal

Core Modules In Drupal:

The following is the list of the included Drupal Core modules and which provides the functionality in the installation and configuration processes.

  1. Block — Controls the boxes that are displayed around the main content.(For More Info http://drupal.org/handbook/modules/block)
  2. Filter — Handles the filtering of content in preparation for display. (For More http://drupal.org/handbook/modules/filter)
  3. Node — Allows content to be submitted to the site and displayed on pages. (For More http://drupal.org/handbook/modules/node)
  4. System – Handles general site configuration for administrators. (For More http://drupal.org/handbook/modules/system)
  5. User — Manages the user registration and login system. (For More Info http://drupal.org/handbook/modules/user)