Change the text of Apply Button on views Exposed form

The following snippet changes the views exposed form Apply Button to Search Jobs. Make the changes in template.php file of the currently enabled default theme. Clear cache to see it work.(Clear class registry cache to be precise.)


function YOUR_THEME_NAME_preprocess_views_exposed_form(&$vars, $hook){
// only alter the required form based on id
// drupal_set_message(t("form id: ".$vars['form']['#id']), 'status', FALSE);
if ($vars['form']['#id'] == 'views-exposed-form-search-openings-page') {
// Change the text on the submit button

Creating PDF Document using DomPDF

* Convert the HTML into a PDF and store it in a particular location.
* In this example, the dompdf library is stored under libraries folder in Drupal.
function ji_custom_convert_pdf($user_html){
//Get path of dompdf folder under libraries
$dompdf = new DOMPDF();
$output = $dompdf->output();
file_put_contents("sites/default/files/resume/".$user->name."_resume.pdf", $output);


Using Entity Metadata Wrapper

The Entity API provides wrapper classes you may use to make dealing with the values of an entities properties and fields easier. Wrappers make it easier to get and set the values of fields and properties as well as to programmatically retrieve additional information about these elements and iterate over lists of values in a consistent manner.

This implies that one need not worry about fetching a node property in the format:

Using State API in Drupal Forms (Custom Conditional Fields)

The following is a snippet on how to enable fields to appear and/or disappear based on the state of other fields.


* Modifications for including State API functionalities. The idea is to hide the fields field_referme_industry
* and field_referme_major_skills, based on the value of another field.
* The functionality can be implemented during the after_build phase
function jc_form_alter(&$form, &$form_state, $form_id) {
//drupal_set_message("Form Id is: $form_id ");
if($form_id == 'referme_node_form') {

Issues with Nivo Slider


Nivo slider is a nice tool for front page slideshows. The reasons you should try Novo are:

  • Allows clickable images
  • Allows separate admin interface to be exposed to clients
  • Allows simple management of slideshows, ordering of slides, overlays etc.

However, Nivo seems to be getting shipped with persistent bugs. The following fixes are required to get expected behaviour from Nivo.

Problem #1. Small image appearing on top left before each transition.
Solution: Add the following to custom CSS:

.nivoSlider img { max-width: none; }

How to enable Ajax for CCK Fields in Drupal 7

The idea is to modify another CCK field based on selection of an item via a select list in another field.

Let us consider a content type called article containing 2 additional fields: article_test_entity - which is an entity reference that displays node titles of all nodes and article_test_entity_type - which is a select list that contains Content Type names list with its key as the actual machine name of the content type. The idea is to restrict the list of node titles displayed on article_test_entity based on the content type selected via article_test_entity_type.



Rules cron based condition code for allowing execution only once



* Part of Rules condition code that returns true if the current time during cron is between 6 am and 7 am
$ji_daily_status = variable_get("ji_daily_report","1"); //Check if the variable is set, if not set it to 1 [First Time]

* This fragment checks if the time is between 6 and 7, if so enables the flag
* If any other time, sets the ji_daily_report so that next time it executes when cron runs between 6 and 7
$time = date('H'); // Get the current time
/* Any arbitrary time - Checks if the time is not between 6 am and 7 am */
if($time < 6 || $time > 7){