Archive for the ‘Drupal’ Category


>

If you are using Ajax module for Drupal Forms which having image button, then you can not submit the form.
To fix that kind of issue then we have to use  ‘#button_type’ => ‘submit ajax-trigger’, attribute to submit button. Below is the sample code…

$path = drupal_get_path(‘theme’, ‘tradenet’).’/images/image_button.png’;
      $form[‘#ajax’] = array(
        ‘enabled’ => TRUE
      );
      $form[‘submit’] = array(
             ‘#type’ => ‘image_button’,
             ‘#access’ => 1,
             ‘#button_type’ => ‘submit ajax-trigger’,
             ‘#src’=>$path,
             ‘#ajax’ => array(‘submitter’ => TRUE ),

            
          );

>Remove colon from label Drupal

Posted: June 8, 2011 in Drupal

>

To remove Colon from label for form elements just add this below code in to your template.php of the active theme. And replace Theme with your theme name. You can find Original code at includes/form.inc

 
function theme_form_element($element, $value) {
  // This is also used in the installer, pre-database setup.
  $t = get_t();

  $output = '

  if (!empty($element[‘#id’])) {
    $output .= ‘ id=”‘. $element[‘#id’] .’-wrapper”‘;
  }
  $output .= “>\n”;
  $required = !empty($element[‘#required’]) ? ‘*‘ : ”;

  if (!empty($element[‘#title’])) {
    $title = $element[‘#title’];
    if (!empty($element[‘#id’])) {
      $output .= ‘ ‘. $t(‘!title !required’, array(‘!title’ => filter_xss_admin($title), ‘!required’ => $required)) .”\n”;
    }
    else {
      $output .= ‘ ‘. $t(‘!title !required’, array(‘!title’ => filter_xss_admin($title), ‘!required’ => $required)) .”\n”;
    }
  }

  $output .= ” $value\n”;

  if (!empty($element[‘#description’])) {
    $output .= ‘

‘. $element[‘#description’] .”

\n”;
  }

  $output .= “

\n”;

  return $output;
}

>Drupal 7 supports RDF

Posted: June 3, 2011 in Drupal, RDF

>

RDF (Resource Description Framework), which is a standard for encoding metadata and other information on the Semantic Web. In the Semantic Web, data processing applications using the dissemination of structured information in a decentralized and distributed all over the web today. RDF is an abstract, how to break information into separate pieces, and even if it is more popularly known in / RDF XML syntax, RDF can be stored in different formats. This article discusses the abstract RDF model, two specific serialization formats such as RDF is used and how it differs from the standard XML, the higher the level of the RDF semantics, best practices, implementation and querying RDF data sources.

Here are the some good Video Tutorials about RDF:


>Using Eclips we can easily apply patch to drupal module.Below are the steps..

Eclipse
To apply patches to code using Eclipse:

1. Menu > windows > open perspective > others > team synchronizing
2. Open the patch file, select all text and copy it to clipboard (Ctrl+ C)
3. Menu > project > apply patch
4. Select clipboard, click next, select the file you want to patch, click finish or next to setup patching options.


>

We can create new custom formatter for CCK fields using hook_field_formatter_info(), below is the example

/**
* Implementation of hook_field_formatter_info().
*/
function myModule_field_formatter_info() {
 
$formatters = array();
  if (
module_exists('filefield')) {
     
$formatters['myFormatter'] = array(
       
'label' => t('My Formatter'),
       
'field types' => array('filefield'),
       
'multiple values' => CONTENT_HANDLE_CORE,
      );
  }
  return
$formatters;
}
/**
* Theme function for myFormatter from hook_field_formatter_info.
* @param $element
*   an array of formatter info and the item to theme. look in $element['#item'] for the field item to theme.
*/
function theme_myModule_formatter_myFormatter($element) {
  return
"themed element"
}
/**
* Implementation of hook_theme().
*/
function myModule_theme($existing, $type, $theme, $path) {
  return array(
   
'myModule_formatter_myFormatter' => array(
     
'arguments' => array('element' => NULL),
    ),
  );
}
?>

>drupal_set_message() in user_logout

Posted: November 15, 2010 in Drupal

>http://drupal.org/node/754560

   $cookieParams = session_get_cookie_params();
    session_start();
    session_set_cookie_params($

cookieParams);
  // Load the anonymous user
  $user = drupal_anonymous_user(session_id());
  drupal_set_message(t(‘You have successfully logged out of the system. Enter your Username and Passwords below to login again.’));


>// required for Drupal 6
module_load_include(‘inc’, ‘node’, ‘node.pages’);
// which nodeform you want
$node_type = ‘YOURNODETYPE’;
$form_id = $node_type . ‘_node_form’;
// maybe add current users info
global $user;
// create a blank node

$node->uid = $user->uid;
$node->name = (isset($user->name) ? $user->name : ”);
$node->type = $node_type;

// Invoke hook_nodapi and hook_node
node_object_prepare($node);
// Or you can also use an exiting node, for example
// $node = node_load(123);
// and the display the form:
$output = drupal_get_form($form_id, $node);

—————————————————————————————
For User Edit Form:

include_once drupal_get_path(‘module’, ‘user’) . ‘/user.pages.inc’;
global $user;
 $output = “”;
 $account = user_load($user->uid);
 $category = ‘account’;
//  print_r($userInfo);
 $output = drupal_get_form(‘user_profile_form’, $account, $category);
return $output;


>$img = ‘‘;
l($img, ‘user/3’, array(‘attributes’ => array(‘class’ => ‘link’, ‘id’ => ‘xxx’, ‘title’ => ‘Title’), ‘html’ => ‘true’));


>function yourtheme_preprocess_node(&$variables) {
if ($your_condition) {
drupal_add_css(path_to_theme(). “/filename.css”, “theme”);
$variables[‘styles’] = drupal_get_css();

drupal_add_js(file_directory_path() .’/javascript.js’, ‘inline’);
$vars[‘scripts’] = drupal_get_js();
}
}

>Drupal: Turn off Register_Globals

Posted: April 21, 2010 in Drupal

>Method 1

Place a file called php.ini in your accounts root directory with the following content: register_globals = false (you can also try using ‘off’, or ‘0’instead of ‘false’).

Method 2

Place a file called .htaccess in your acccounts root directory with the following content:
php_flag register_globals off