css tip : set margin parameters

31 10 2009

if you get confuse and feel hard to remember the parameter sequence for ‘margin’ tag in css then just bookmark the url of my this post :)

General Format:

margin:Toppx Rightpx Bottompx Leftpx

 

Example:

<div style=” margin:14px 10px 7px 16px;”>
This inline css code will make this div to produce margin: 14px at top, 10px at right, 7px at bottom and 16px at left

Hope this will help someone ;)





JQuery form validation :: a good solution

29 10 2009

hay Friends,

Do you want to validate your form using JQuery and want it to be Inline ?? so Here is the solution for that:
http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/
I realy appericiate this article so thought to share with you all.

Hope you guys would love it like me ;)





Drupal 6 Cheat Sheets

27 05 2009

hay friends;

I was in search for some cheat sheets that could easily help me to remember the main constructs of Drupal 6 programming and eventually i found :) .
You may download the cheat sheet for Drupal 6 here:

Hope these would be helpful for someone other too.





Subversion :: some handy commands for SVN

20 05 2009

hello friends ;


If you guys are using SVN for version controlling and willing to get a list of handy commands that are usually used while operating with SVN (Subversion), then you must visit these pages:

  • http://wiki.greenstone.org/wiki/index.php/Useful_SVN_Commands
  • http://lipidity.com/apple/subversion-basics/
  • http://www.oxygenxml.com/doc/ug-oxygen/cmd-line-quick-reference.html

Those fortunate who have abundant time for learning should visit this link http://svnbook.red-bean.com.
SVN may really ease your life if you are really interested ;)





Magento: retrieve base url path

20 05 2009

If you are working in Magento and trying to find the base URL path for your Magento installation then you must use try this line of code:
echo Mage::getBaseUrl();

It will fairly return you the base path Url. Hope this tip will help someone :) .





Drupal Book :: drupal 6 javascript and jquery

4 05 2009

hay Friends,
Another good book for Drupal community: Drupal 6 JavaScript and jQuery released by Packt. This is 2nd great book by ‘Matt Butcher’ released on March 2009. This book greatly explain how to make it easy to work in Drupal using jQuery or simple java script. I read a free chapter of this book and i found it well versed about using JQuery in Drupalish modules. I am really dying to read this cool book :P .

A good Book for Drupal 6 and JQuery

A good Book for Drupal 6 and JQuery

Hopefully, I’ll get it very soon INSHAALLAH :) .





Drupal 6 :: Custom Search Box

29 04 2009

hello Friends,

I came across a scenario where it was needed to customize Drupal 6 search box for my current drupal based theme and this customization was needed to :

  1. Change Default text on submit button
  2. Change Default text in search box (Search this site)
  3. When user clicks on search box, default search box text should disappear

All of above tasks should be easily attainable if you are not working in Drupal but it doesn’t mean that these are very difficult while working in Drupal. Somehow, it is a little tricky.

Most recommendable and suitable way that i found was to create a new module and use form_alter hook to track the search form events and bring all above changes in these events.

I’ll recommend you to read this thread: http://drupal.org/node/214592 where Heine helped alot to get clear ideas about form_alter hooks and their usage. Hopefully it will help you too.

Now lets move towards the solution.

First of all create a new module under sites/all/modules with any name. Say it is named ‘abc’ (supposing that you will be aware of the process of module creation and all files needed to create for a new module in Drupal). Open your abc.module file and create a new function there named ‘abc_form_alter‘ having parameters (&$form, $form_state, $form_id).  Basically, ‘abc_form_alter‘ will implement hook_form_alter (explained well http://drupal.org/node/214592) and will use this function to grab search form events and implement my search box changes on triggering of those events.  So this is the summary of our solution and following code you’ll write in abc.module file.

function abc_form_alter(&$form, $form_state, $form_id) {
  if($form_id=='search_theme_form')
  {
	$form['submit'] = array('#type' => 'submit', '#value' => t('[ GO ]'));
	$form['search_theme_form']['#default_value'] = 'Search My Site';
	$form['search_theme_form']['#attributes'] = array('onfocus' => "if (this.value == 'Search My Site') {this.value = '';}" );
  }
}

and That’s All :) .

Lets make a short review on above code,

This condition if($form_id==’search_theme_form’) will check if ’search_theme_form’ is about to render then do following stuff:

 $form['submit'] = array('#type' => 'submit', '#value' => t('[ GO ]'));

Above Line will change the default submit button text and make it to be [ GO ]

 $form['search_theme_form']['#default_value'] = 'Search My Site';

This code Line will Change Default text in search box and make it to be ‘Search My Site’

 $form['search_theme_form']['#attributes'] = array('onfocus' => "if (this.value == 'Search My Site') {this.value = '';}" );

This final code line gives the way to change any attribute for this text box (you may use it to change the default css class used for search box, too). Here i changed the ‘onfocus’ attribute and wrote the javascript code so when user click on search box for searching some keyword, search box’s default text (Search My Site) should get vanished.

One last thing, if you’r at very basic level in Drupal or even not a programmer then i’ll recommend you to go for this module Custom Search Box. This module is good but keep in mind that you won’t have everything in your hand while using this module but above process can help you to play freely with search form attributes.

I hope this post will open new horizons for you to customize any Drupal based Form :) .





Drupal theme Anatomy

7 04 2009

hello Friends,

For those who are starting to learn Theme development of Drupal, following image will help a lot to get clear idea for Drupal theme Anatomy. I found this image while surfing on internet so thought to share with you.

Drupal theme Structure and anatomay

To Learn Drupal theme Structure and Anatomay

Keep Happy Drupaling! :)





Start Content Management in Joomla!

15 03 2009

hello Friends,

I feel myself lucky that i got very good chances to work on different Content Management Systmes (CMS) like Magneto, Drupal, WordPress and Joomla!.
This is not a bise statement that each of these CMS are very easy to go for programmer/non-programmer. Though each of these CMS have their own speciality or drawbacks but i’ll reserve that explaination for another post :P .

Here i am going to tell you some Magics of Joomla! and will try to let you know why Joomla! is so much popular among web development community.

“Joomla is an award-winning content management system (CMS), which enables you to build Web sites and powerful online applications. Many aspects, including its ease-of-use and extensibility, have made Joomla the most popular Web site software available. Best of all, Joomla is an open source solution that is freely available to everyone.”

These quoted lines are said by official website of Joomla and gues what? I found Joomla more then what they told :) .Joomla’s  Admin Area is very wisely arranged and the have coped a huge stuff of options in a very light manner. This is the beauty that let someone manage  the things with great ease.

I remember the day when i downloaded the Joomla and installed at my localhost. Just like any good CMS, it’s installation was very easy. After my Login in Admin section, i thought that Joomla seems complex to manage but soon it was changed.
My first thought was just because of unawareness about how content is managed in Joomla. I found some very good video tutorial that changed my thinking. You may watch these video tutorial over here.
For understanding the basics of content management, this link will help you a lot.

If you are newbie in Joomla then do not forget to install example data for Joomla. Joomla installations asks you for it’s installation too.

Another greatness about Joomla: A big Repository of extensions and modules is available on Joomla’s official website .  Just after some short search there, you may get rid of time spoiling on Joomla Component development. Same flag is valid for Module development of Joomla. Remember that ‘Module’ and ‘Component’ are 2 different things in Joomla and i’ll try to explain about it in my next post that will help you to know about ‘Template Development for joomla’.

Hay! have i told you that there are lots of free joomla templates availabale to download and use? yes it is so :) .
I found http://www.bestofjoomla.com and http://www.joomla24.com with lots of free download able templates. Don’t forget to see the Version compatibility while downloading the template, it will save your time.

Well, this post was just a start up and you’ll see some detail posts for ‘development in Joomla’ , both for ‘Joomla template’ and ‘Joomla component/module’.

Thanks :)





Mysql::Import/Export Database using SSH

12 03 2009

MySQL databases are not backed up like ordinary files. Even if it were possible, it would not be a good solution, as it could corrupt the database by doing so.

To back up your database, ssh to your account, then use the mysqldump command:

    mysqldump -ppassword DatabaseName > db.sql

(‘db.sql’ is the name of your backup dump file, which you can change to whatever name you choose)

That backs up the whole database in standard SQL text format. Both the structure (like CREATE table command) and data (like INSERT command) statements, can be backed up separately, which is usefull in many cases. Check:

mysqldump --help

for all the command line options.

To restore the dump, just type:

    mysql -p dbname < db.sql

Note that the structure dump won't work if tables already exist. The backup will not change or replace the structure.

For the data dump (the INSERT commands) it will append any new data if it does not yet exist.

If you have a database that is in frequent use, such as one linked to a dynamic web interface being updated by your web site visitors, it is a good idea to make a daily backup of the data.

To transfer a database, create the dump as described above, use ftp to upload it on the second server, and then restore it as above.

Backing up the database is not done through an ftp database directly. You first need to generate an sql dump, and then download this dump.

Use the following mysqldump command:

    mysqldump -ppassword username > somefile.sql

Then use the following command to view the dump:

    view somefile.sql

(exit with: q!)

To put the file back:

  • upload the file
  • edit it with a text editor, adding the below line to the top:
      use databasename (which is the same as your username)
  • save the file and issue the command:
      mysql -ppasswd < somefile.sql

All of the database will be generated, including structure. For more details, use

    mysqldump –help