root's blog
Drupal - Autocomplete with node title and image
Today one of our clients wanted us to enhance product selector autocomplete field, and instead of displaying product name it should display name with product thumbnail. First thing on my mind was, its gonna take time + lot of AJAX and Jquery.
But as always in Drupal there is a module that does that! Half an hour later I delivered enhanced autocomplete to my client!
Here is how I did it:
Drupal: How to display block only on nodes of certain content type?
Edit your block and select "Show if the following PHP code returns TRUE (PHP-mode, experts only)" and insert following php code:
<?php
//Read URL
$path=$_GET['q'];
//If URL is node page
if ( strpos($path,'node')===0){
//Parse URL to get nid
$links=explode("/",$_GET['q']);
$nid=$links[1];
//Load node
$node=node_load($nid);
//Display block only if node is of certain content type
if($node->type=='YOUR CONTENT TYPE'){
return TRUE;
}
}
?>
How to import/export database using MySql command line
The easiest way to export is to use command prompt (cmd):
mysqldump -u USER -p PASSWORD DATABASE > filename.sql
To import database from dump file use:
mysql -u username -p password database_name < filename.sql
Drupal and WYSIWYG
When you install Wysiwyg module and one of its editors some time if you are trying to do some decoration to text it works in editor but when saved on node all styling is lost!
But there is an easy problem on how to solve this. Just go to site configuration -> input format, and disable html filter.
Drupal: How to disable module from database
- First you open phpmyadmin
- Then you go to the database that drupal is working on
- Click on the SQL tab
- In the text field type the following query :
UPDATE system SET status = 0 WHERE name = 'module_name' LIMIT 1;
*where "module_name" is name of module you want to disable.
How to add Login and Register as menu items in Drupal?
You want to add Login and Register to your menu but you don't want them to be displayed for authenticated users? In Drupal 6 there is easy way to do it! Just follow this steps:
1. Go to menu in where you want to add new menu items and click on Add Item.
2. As Path enter user/login and Login as menu link title.
3. As Path enter user/register and Register as menu link title.
You will now have Login and Register in your menu and they will be displayed only for anonymous users.
How to set frontpage for different languages in Drupal?
One of the biggest problems when setting multilingual site in Drupal is having different frontpage for different languages. When user goes to www.emailciti.com he will view frontpage of default language, but when user goes to www.emailciti.com/ar instead of frontpage in Arabic language he will see same frontpage as for default language. In following steps we will explain how we solved this issue:
1. Enable Path module.
2. Create new node where we will put Arabic frontpage content.
How to reset admin password in Drupal?
- First you open localhost → phpmyadmin
- Then you go to the database that drupal is working on
- click on the SQL tab
- in the text field type the following query :
update users set pass=md5('NEWPASS') where uid = 1;
*where "NEWPASS" is your new administrative password.
- Then click on the GO button.
How to create custom Photo Gallery in Drupal.
In this tutorial I will explain how to create customized Photo Gallery in Drupal in 5mins.
First of all we will need to download and enable following modules:
Web2make recommends 10 must have Drupal modules.
Drupal is one of the most flexible, modular and customizable open source Content Management Framework (CMF) powering thousands of websites. With more than 4000 contributed modules it is not an easy task to get started. Therefore web2make made a list of 10 must have Drupal modules.
1. Views
The Views module provides very easy to use user interface to create all kind of SQL queries you need.

