PHP

Thursday, May 30, 2013

Simple Drupal 7 module

Creating a basic Drupal module is not so hard if you have some knowledge of PHP. All you need is some basic ideas on Drupal directory system. All third party modules are stored in /sites/all/modules/modulename folder. So we are going to create a module and place it there. To run a Module you will need two files "modulename.info" and "modulename.module", note modulename is the name of the module you are going to create.




  1. Create a modulename.info file with the following informaiton
    name = modulename
    description = My first module
    core = 7.x
  2. Now create a modulename.module file with the following content
  3. Go to the module section(http://sitename/admin/modules) you will see the module with a check box before it. Check it and click save button down below.
  4. Go to http://sitename/customurl/firstmodule (same url you defined in modulename_menu function) and you should see the page content as "Hello World".







Monday, May 27, 2013

List of Drupal modules you must have

Modules play an important role in developing a Drupal site. Here are the list of some important Drupal modules you need to run a basic site.

  1. Backup & Migrate: This module is specially for developers. This module help to dump database and keep scheduled database backup.
  2. Path Auto: This is one of the best module in Drupal. It is used for automatic path aliasing. It requires Token module to operate. By default Drupal's URL looks like : http://www.site.com?q=node/1, by using Path Auto module this URL can be converted to something like this: http://www.site.com/CUSTOMURL. This URL looks more beautiful than the previous on and even better for Search Engines.
  3. Views: One of the best module in Drupal. This module is used to customize your site's content view sorting, paging, creating content filters,creating pages and blocks and many more. It  requires Chaos Tool Suite module to operate. Suppose you want to create a page where you want to list some articles with paging and sorting feature. To do this, Views module will provide you an interface where you can select articles, create a custom page name to show the list of articles, you can even create a filter to search the articles. You can do this all without a single line of PHP code. 
  4. Captcha: Everybody wants their website's form to be secure. Nobody wants to see the list of spam emails in their inbox. This module works best if you want to control spam in your site's forms. It supports, Math captcha, Re-Captcha and image captcha.
  5. Page Title: It provides us the ability to customize the page title of our Drupal site pages. We can customize the page title using certain tokens or content types. Mostly used for Search Engine Optimization.
  6. IMCE: Best module for uploading, re-sizing, creating thumbnails from images. Provides support for inserting image in textareas. Demo
  7. Google Analytics: Seo Module, it makes easy to insert the google analytic script in our website.
  8. ColorBox: This is a lightbox plugin for jQuery. If you want to display your site's content and images in an overlay or frame then this module is best. Demo