Return to Snippet

Revision: 25686
at April 6, 2010 00:11 by zachharkey


Updated Code
<?php
// Example 1:
// Renders the body field as format_id '4' (i.e., Markdown) then saves 
// as format_id '3' (i.e, Full HTML).
//
// Run all enabled filters for format_id '4' on the body field.
$object->body = check_markup($object->body, 4);
// Change $format to format_id '3'.
$object->format = 3;
node_save($object); 



// Example 2:
// Renders several CCK fields as format_id '4' (i.e., Markdown) then saves 
// as format_id '3' (i.e, Full HTML).
//
// Run all enabled filters for format_id '4' on $field_notes, $field_description and $field_dimensions.
$object->field_notes[0]['format'] = check_markup($object->field_notes[0]['value'], 4, TRUE);
$object->field_description[0]['format'] = check_markup($object->field_description[0]['value'], 4, TRUE);
$object->field_dimensions[0]['format'] = check_markup($object->field_dimensions[0]['value'], 4, TRUE);
// Change $format to format_id '3' for all three fields.
$object->field_notes[0]['format'] = 3;
$object->field_description[0]['format'] = 3;
$object->field_dimensions[0]['format'] = 3;
node_save($object); 


// Example 3:
// Simultaneously renders CCK field $field_description and migrates 
// the new value to the default body field.

$object->body = check_markup($object->field_description[0]['value'], 4, TRUE);
node_save($object);
?>

Revision: 25685
at April 6, 2010 00:09 by zachharkey


Updated Code
<?php
/**
 * Example 1:
 * Renders the body field as format_id '4' (i.e., Markdown) then saves as format_id '3' (i.e, Full HTML).
 */
// Run all enabled filters for format_id '4' on the body field.
$object->body = check_markup($object->body, 4);
// Change $format to format_id '3'.
$object->format = 3;
node_save($object); 
?>

<?php
/**
 * Example 2:
 * Renders several CCK fields as format_id '4' (i.e., Markdown) then saves as format_id '3' (i.e, Full HTML).
 */
// Run all enabled filters for format_id '4' on $field_notes, $field_description and $field_dimensions.
$object->field_notes[0]['format'] = check_markup($object->field_notes[0]['value'], 4, TRUE);
$object->field_description[0]['format'] = check_markup($object->field_description[0]['value'], 4, TRUE);
$object->field_dimensions[0]['format'] = check_markup($object->field_dimensions[0]['value'], 4, TRUE);
// Change $format to format_id '3' for all three fields.
$object->field_notes[0]['format'] = 3;
$object->field_description[0]['format'] = 3;
$object->field_dimensions[0]['format'] = 3;
node_save($object); 
?>
<?php
/**
 * Example 3:
 * Simultaneously renders CCK field $field_description and migrates the new value to the default body field.
 */
$object->body = check_markup($object->field_description[0]['value'], 4, TRUE);
node_save($object);
?>

Revision: 25684
at April 6, 2010 00:08 by zachharkey


Updated Code
<?php
/**
 * Example 1:
 * Renders the body field as format_id '4' (i.e., Markdown) then saves as format_id '3' (i.e, Full HTML).
 */
// Run all enabled filters for format_id '4' on the body field.
$object->body = check_markup($object->body, 4);
// Change $format to format_id '3'.
$object->format = 3;
node_save($object); 


/**
 * Example 2:
 * Renders several CCK fields as format_id '4' (i.e., Markdown) then saves as format_id '3' (i.e, Full HTML).
 */
// Run all enabled filters for format_id '4' on $field_notes, $field_description and $field_dimensions.
$object->field_notes[0]['format'] = check_markup($object->field_notes[0]['value'], 4, TRUE);
$object->field_description[0]['format'] = check_markup($object->field_description[0]['value'], 4, TRUE);
$object->field_dimensions[0]['format'] = check_markup($object->field_dimensions[0]['value'], 4, TRUE);
// Change $format to format_id '3' for all three fields.
$object->field_notes[0]['format'] = 3;
$object->field_description[0]['format'] = 3;
$object->field_dimensions[0]['format'] = 3;
node_save($object); 

/**
 * Example 3:
 * Simultaneously renders CCK field $field_description and migrates the new value to the default body field.
 */
$object->body = check_markup($object->field_description[0]['value'], 4, TRUE);
node_save($object);

Revision: 25683
at April 6, 2010 00:08 by zachharkey


Initial Code
/**
 * Example 1:
 * Renders the body field as format_id '4' (i.e., Markdown) then saves as format_id '3' (i.e, Full HTML).
 */
// Run all enabled filters for format_id '4' on the body field.
$object->body = check_markup($object->body, 4);
// Change $format to format_id '3'.
$object->format = 3;
node_save($object); 


/**
 * Example 2:
 * Renders several CCK fields as format_id '4' (i.e., Markdown) then saves as format_id '3' (i.e, Full HTML).
 */
// Run all enabled filters for format_id '4' on $field_notes, $field_description and $field_dimensions.
$object->field_notes[0]['format'] = check_markup($object->field_notes[0]['value'], 4, TRUE);
$object->field_description[0]['format'] = check_markup($object->field_description[0]['value'], 4, TRUE);
$object->field_dimensions[0]['format'] = check_markup($object->field_dimensions[0]['value'], 4, TRUE);
// Change $format to format_id '3' for all three fields.
$object->field_notes[0]['format'] = 3;
$object->field_description[0]['format'] = 3;
$object->field_dimensions[0]['format'] = 3;
node_save($object); 

/**
 * Example 3:
 * Simultaneously renders CCK field $field_description and migrates the new value to the default body field.
 */
$object->body = check_markup($object->field_description[0]['value'], 4, TRUE);
node_save($object);

Initial URL

                                

Initial Description
While these examples convert Markdown fields to HTML for use in CKEditor, the same method can be used to render the filters of any input_format.

Initial Title
Convert Drupal content fields from Markdown to Full HTML for display in CKEditor

Initial Tags
drupal

Initial Language
PHP