Category Archives: Drupal

Change title from node add form in Drupal

Changing title from node add/edit form in Drupal is pretty simple. You can do that with Drupal hooks from your custom module. Here is the simplest way to do that

function mymodule_form_alter(&$form, $form_state, $form_id) {
if($form_id == ‘mynodetype_node_form’){
drupal_set_title(t(“Edit My new title”));
drupal_set_title(‘My new title’);

Leave a comment

Posted by on August 12, 2012 in Drupal, PHP, Uncategorized


Using Nice Menus with Drupal Primary Links

Nice Menus module help us to make Drupal menus into drop down or flyout (left or right) menus. This module only use CSS for most of the browsers (Firefox, Opera, Safari, Chrome etc.) and with additional Javascript for troublesome browsers (IE).

  • Nice Menu provides up to 10 (ten) blocks configure with different drupal menus item.
  • It provides default styling which can be override from sites theme CSS files.
  • User can customize menus functionality with the theme functions


The module includes a default CSS layout file (nice_menus_default.css) which is loaded for nice menus. You can change the default layout if you are not like this. This is suggested that you can create a new customized CSS file and replace the default CSS file from Administer -> Themes -> Configure -> Global settings -> “Path to custom nice menus CSS file” here. This ensures smooth future upgrades as no editing of the module files is necessary. Also note that you should not edit the regular nice_menus.css file since this contains the “logic” that makes Nice Menus work. A good starting point for your custom file is to make a copy of the default file, then edit it to taste. You can look through Nice Menus CSS Examples for some basic CSS edits.

Nice Menus Custom

Advanced theming

If you’re creating or modifying your own theme, you can integrate nice menus more deeply by making use of these functions:
theme_nice_menus() — themes any menu tree as a nice menu.
theme_nice_menus_primary_links() — themes your primary links as a nice menu.

Leave a comment

Posted by on February 13, 2012 in Drupal


Tags: ,

“OR” search with Apache Solr

Apache Solr is most popular and powerful open source enterprise search platform from the Apache Lucene project. I am using Apache Solr search platform mostly with my Drupal projects. Recently I got one requirement from one of my client to do search with keyword and taxonomy term for a specific content type. Where user can select multiple taxonomy term i.e. we need to do a OR search between the taxonomy terms based on user selection.

After doing some investigation we found that Drupal Apache Solr module doesn’t provide any custom search facility that will meet the client requirement. So I have planned to write a custom module for this. While working on custom module I found a real problem, it seems Faceted Search doesn’t allow to do OR search. So, I have started search on web again. After doing some searching I found one solution how to do “OR” search with Apache Solr Faceted search.

I have modified the Apache Solr query from my custom module by implementing “hook_apachesolr_modify_query“.

  • Collect the current subquery with apache_drupal_query() function.
  • Add taxonomy term ids into the collected sub query with add_filter() function.
  • Finally add all subquery into main query with “OR” operator.

function my_module_apachesolr_modify_query(&$query, &$params, $caller) {
$term_ids = explode(‘,’, $_GET[‘tids’]);
$subquery = apachesolr_drupal_query();
foreach ($term_ids as $key => $value){
$subquery->add_filter(‘tid’, $value);
$query->add_subquery($subquery, ‘OR’);
watchdog(“my_module”, “Add subquery search for selected term id from my module search page.”);

Leave a comment

Posted by on February 8, 2012 in Drupal


Tags: , ,

How to add single on/off checkbox with CCK in Drupal

Always I have to spend some extra time while going to add a single on/off checkbox with CCK in Drupal. Each time I think to write a post about it and finally I am going to documented it help others.

This is pretty simple to work with CCK fields in Drupal. But adding on/off checkbox is different from other CCK fields.

  • To add a single on/off checkbox go to Manage Field option for the specific content type
  • Add a new field with single on/off checkbox selection
Add single on/off checkbox

Add single on/off checkbox

  • Into allowed values list we need to add two entry. First one will be ignored and second one will be display into content add/edit page.
Add two values into allowed values field

Add two values into allowed values field

  • Finally checkbox will appear into content add/edit page
Single on/off checkbox

Single on/off checkbox

1 Comment

Posted by on February 8, 2012 in Drupal


Tags: ,