Coding

Allow HTML markup in quicktabs

Technologies: 

Quicktabs by default strips html tags in Quicktab title by default. To add additional markup of text changes, hook_quicktabs_alter() is not sufficient the quicktabs tabset needs to be overriden to allow html markup in titles.

hook_quicktabs_alter() to modify title. In the example modification for the first tab is done

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.)

<?php

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

<?php
/**
* 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
 
set_include_path(libraries_get_path('dompdf'));
  require_once
"dompdf_config.inc.php";
 
$dompdf = new DOMPDF();
 
$dompdf->load_html($user_html);
 
$dompdf->render();
 
$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:
$node->field_name['und'][0]['value']  

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.

<?php

/**
* 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') {

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.

<?php

/*