Shortcode for drupal mp3 player

Shortcode Installation:

This shortcode Installation is like with all normal drupal modules:
extract the ‘mishu_swf.zip’
modules directory from your website (typically sites/all/modules).
go to modules find swf_tools_mod and active it

Shortcode Featur:

1. Shortcode for display mp3 player
2. mp3 player display inline
3. Customize play and sotp icon
4. Use multiple mp3 player
5. In the case of multiple player when you play one others will be pause automatically

Shortcode Usage:

Use shortcode in your post editor like [mishu_swf file=”sites/default/files/01.mp3″]
your short code name must be mishu_swf.
file is the parametar which is contain the mp3 file location
Download shortcode for drupal mp3 player
Hope you like drupal mp3 shortcode.

Web Form Page

 Get current node id Drupal 6

$nodeID = AM_get_current_node();
/**
 * AM_get_current_node()
 *
 * Return current node ID
 *
 * Author: Mishu
 */
function AM_get_current_node() {
    if ( arg(0) == 'node' && is_numeric( arg(1) ) ) {
        return arg(1);
    }
}

 
 

Web Form

Programmatically Create Web form Component Drupal 6

Easily create web form component programmatically (drupal 6).

//Field defination
$component_email = array(
    'type' => 'textfield',
    'nid' => $nodeid,
    'clone' => '',
    'name' => 'email',
    'form_key' => 'app_email',
    'extra' => Array
        (
            'title_display' => 'before',
            'private' => 0,
            'disabled' => 0,
            'unique' => 1,
            'conditional_operator' => '=',
        ),
    'cid' => 2,
    'required' => TRUE,
    'validate' => 'email',
    'mandatory' => 1,
    'weight' => 1,
    'value' => '',
);
AM_webform_comp_create($component_email);
/**
  * AM_webform_comp_create($component_email)
  *
  * Programmatically Create Webform Component
  *
  * Parameters: $component_email(array);
  *
  * Author: Mishu
  */
function AM_webform_comp_create( $component_email ) {
    //include webform.components form webform module
    module_load_include('inc', 'webform', 'includes/webform.components');
    //Get current node id
    if ( arg(0) == 'node' && is_numeric( arg(1) ) ) {
        $nodeid = arg(1);
    }
    //Form key exist or not
    $form_email_key_exist = db_result(db_query("SELECT form_key From webform_component WHERE nid='$nodeid' AND form_key='app_email'"));
    //If form key not exit insert the email field
    if(empty($form_email_key_exist)) {
        webform_component_insert($component_email_id);
    }
    //update webform table
    $tableName = 'webform';
    $data = array(
        'nid' => $node->nid,
        'confirmation' => '',
        'confirmation_format' => 1,
        'redirect_url' => '<confirmation>',
        'status' => 1,
        'block' => 0,
        'teaser' => 0,
        'allow_draft' => 0,
        'auto_save' => 0,
        'submit_notice' => 1,
        'submit_text' => '',
        'submit_limit' => -1,
        'submit_interval' => -1,
        'total_submit_limit ' => -1,
        'total_submit_interval ' => -1,
    );
    AM_dbInsert($tableName, $data);
    $tableName = 'webform_roles';
    $data = array(
        'nid' => $node->nid,
        'rid' => 1,
    );
    AM_dbInsert($tableName, $data);
    $tableName = 'webform_roles';
    $data = array(
        'nid' => $node->nid,
        'rid' => 2,
    );
    AM_dbInsert($tableName, $data);
}
/**
  * AM_dbInsert()
  *
  * Insert data into a table
  *
  * Parameters: $table(string), $data(array) | Example: $table='test'; $data = array( 'field_name' => 'value');
  *
  * Author: Mishu
  */
function AM_dbInsert($table, $data) {
    $field = implode(", ", array_keys($data));
    $values = "'" . implode("', '", array_values($data)) ."'";
    $tbfstfld = db_result(db_query("SHOW COLUMNS FROM {$table}"));
    $StudentPro = db_query("INSERT INTO {$table} ($field) values ($values)");
    if($StudentPro === true) {
        return db_last_insert_id($table, $tbfstfld);;
    }
}

Drupal web form component

It is very difficult to create web form component manually if you have a lot of content with web form.

 Drupal web form

twiIf you like to creating web form component programmatically or find any bug please leave me a comment. Hope you enjoy my Drupal web form post.