Archive for Drupal

Using Drush ( Power tool for Drupal ) in Windows XP

At first when I saw drush i thought it’s not that handy as it seems to be. I thought some geek created this just to have fun and feel command line flexibility. But after i dig deeper i found it amazing. If you understand how to use drush you will be amazed by it’s power.

Now what is drush .. drush is a command line shell and Unix scripting interface for Drupal. as stated in here.  The most noteable features of drush from my point of view is :   module enable/disable, update script,  module download, cache clear. Just from command mode i can check latest version of module and dl them and enable them in just simple 3 to 4 commands.

I am not going to briefly explain drush functionality but will try to explain how to run drush in your system in this case Windows XP ( :P ) .  Here it goes:

  • Download the latest version of drush from drupal
  • Now open Command prompt and check and set initial settings.
    • Type ‘php’ and press enter if php command is not found then set php.exe path in your Environment
    • Also add the drush path into the environment path
    • By Closing and opening  command prompt again. check by typing ‘drush’
    • If by typing ‘drush’ shows error regarding drush.php open drush.bat file in an editor and  add the abosulute path of drush.php in that bat file.
    • This will fix the drush.php path problem.
  • Let’s play with drush. Open command prompt again and traverse to a drupal installation for example:  ’cd d:/www/mydrupal’  and then type  ’drush status’. It will show initial settings of mydrupal installation. If it does not check for settings and environment path.

Drush has some nice extensions. You can play around with them. Here is another simple tip for you. If you study drush you will definately like “drush -v dl ” and ‘drush info” command. “drush info <module_name>” shows particular modules downloadable version and “drush -v dl” can help you to download and copy the file directly into your installation by just 1 single command. But to use ‘drush -v dl’ is little tricky. It uses gzip and tar command to extract the downloaded module file. You can download gzip and tar exe for windows from here.

It seems some ppl did able to use gzip and tar without any hasle but in my case i had trouble with tar. So i hacked into the core of drush and changed the tar command into izarce . If you face problem with tar then go with izarce. It worked for me.

Oops. To use izarce first install the command line version. Then add the izarce location into your environment path. THen goto drush directory and open file ‘drush\commands\pm\package_handler\wget.inc’.  Now find the line which says:

drush_shell_exec(“tar -xf $tarpath -C \”$path\”");

Now replace this with

drush_shell_exec(“izarce -e -d -p”. $path . ” $tarpath”);

It worked for me hope this does for you too. Have a nice drushed life.

[ N.B. At first i tried to use 7zip instead of izarce and gzip+tar but they have some absolute path issue; the solution of which i could not find. So, if you do know of any solution better than this do let me know.

For setting environment   press "windows key+ pausebreak" >> Advanced >> 'environment variable' >> now find variable path .. :) enjoy]

Comments (1)

My favorite Modules in Drupal

I have been planning to write a post regarding drupal for quite a long time. Today i am enlisting some of the modules which I use most and a sentence or 2 to explain their task:

  1. Administration Menu:
    It’s an elegant Navigation menu for Drupal for Administration. It creates the navigation menu on top of the site in a sleek bar. I always put this in my development and remove the navigation block. Don’t forget to add $closure in your custom theme when you are using this module.
  2. WYSIWYG API : ( Previously TinyMCE )
    An elegant RICH text editor is enough to satisfy the client or me. Though with many unwanted behavior or so.. I still like to use such module in my installation. IMCE is another module to integrate with TinyMCE which supports Image Upload mechanism on Flow.
  3. CCK ( Content Construction Kit ):
    This can add Additional Fields in your custom content. Must have tool.
  4. VIEWS:
    Drupal to me is uncomplete without CCK and VIEWS modules. These two can make like as easy as possible. Views helps you to fetch contents they way you want it.. and Theme wizard is a bless.
  5. WEBFORM:
    To fetch some additional data or Registration form, most time I depend on this module. This has some cool features like sending mail when someone fill ups the form. Must have tool for all.
  6. Date:
    It provides a date field for your contents. Really Helpful.
  7. Acidfree:
    Many may say it’s not ready for production use. But i use it a lot where i need a gallery.  It has some nice features too.
  8. Lightbox2:
    Combine this with Acidfree you will get a nice gallery.
  9. Image :
    If you need an image Content, here you have it.
  10. Pathauto:
    If you are tired of calling your contents by node/1 or node/420 then this can help you to automate or manual entry to change it to meaningful reference.
  11. Calendar:
    To create an Event page, Calendar module is very helpful.
  12. Devel :
    Though this one is a geeky module but it helps a lot to understand how drupal works out.
  13. Contemplate:
    I have not used this in any place but i think it can be helpful for many that’s why i am enlisting it here.
  14. Jquery Update:
    Pretty self explanatory.. i think.

There are many other modules which can be enlisted here but i think these are the basic and must have modules to have to start your work.  I will add more modules later .. please drop you suggestion .

Leave a Comment

Super Scratch Development-1: Ideas from CodeIgniter & Drupal

There are a good number of developers i have seen who still develop sites using Scratch Development. Each and every one of them have their own excuses over CMS and MVC based frameworks. Even most of the fresh students from universities never heard of Web Application Frameworks ( very sad ). So, guiding new freshers to the world of Web Application Framework is little tough and sometimes they get frustrated. In such cases i let them develop using scratch but give them some tools and ideas from codeIgniter and Drupal. After working with such things sooner they become more interested on newer things like Frameworks.

Here i am not going for details just an overview. Otherwise i have to write a whole e-book :D … Is there any good rich guy who can sponsor me to write a book on this .. :) )

  1. BASE PATH / Database Operation
    Freshers and other experienced scratch developers mostly uses Relative path ( ./ or ../) to target their image or PHP files. And for database activity i can bet 70% scratch coder uses ( common.php or common.inc) where they put a connect_to_db function which connects to database.For PATH location i usually suggest to use a ‘config.php’ :D file and store necessary paths like Image folder, JS etc.. and in your code use such folder location to locate your images and other stuffs.

    Now for database activity… in this case i take the risk and usually introduce ActiveRecord of CodeIgniter to the freshers. And for this reason i am very thankful to Hasin Hayder for separating ActiveRecord from CodeIgniter. I used his separation :D .

  2. Template Engine ( tiny but strong / Smarty)
    PHP template Engine can reduce coding lines and it gives a great opportunity to reshape or change the orientation of the site as clients and bosses likes to change their minds very often. In my personal opinion i liked ‘tiny but strong’.

    Ideas From drupal

    : I very much :D like the block mechanism of drupal. In drupal you can put your block in any particular place like left sidebar, right sidebar, footer etc even by theme customizing you can create your particular region where you can put your block . So, this can be easily inherit by using tiny but strong. By using a database table which specify the position of a particular block and some individual block code; you can achieve such functionality. Even the header and footer can be handled more efficiently.

  3. TinyMCE / FCKeditor
    In every web project there are always a number of static pages needs to be handled :( like contact us, about us etc. Such cases can be handled by Rich Text Editors like TinyMCE and FCKeditor. Keep the contents of those static pages inside the database. And provide TinyMCE ( my personal favorite ) to edit such contents. In those pages you can retrieve the body content from database.

    you can see their comparison with others :D

to be continued …………………………………….. :D

Leave a Comment