What I would like to achieve is the this:
- Develop new content type
- Add two fields to the content type : XML, XSLT, / text areas
- When I use this content type later on I want to be able to paste some XML into the XML field, some XSLT into the XSLT field. When I save my new content I want the XML to be translated into HTML.
So in view mode I would always see the HTML, 'edit' mode would give me away of manipulating the XML / XSLT
I started following this tutorial: http://drupal.org/node/231019. But that does not cover how /where to save my new fields. This is how far I got following the tutorial:
/**
* Implementation of hook_node_info().
*/
function xmlparser_node_info() {
return array (
'node_amlparser'=>array(
'name' => t('XML Parser'),
'module' => 'xmlparser',
'description' => 'This module takes XML and XSLT to generate HTML'
)
);
}
/**
* Implementation of hook_perm().
*/
function xmlparser_perm () {
return array ('create xml content','edit own xml content');
}
/**
* Implementation of hook_access().
*/
function xmlparser_access($op, $node, $account) {
if ($op == 'create') {
// Only users with permission to do so may create this node type.
return user_access('create xml contene', $account);
}
if ($op == 'update' || $op == 'delete') {
if (user_access('edit own xml content', $account) && ($account->uid == $node->uid)) {return TRUE;}
}
}
/**
* Implementation of hook_form().
*/
function xmlparser_form (&$node, $form_state) {
$type = node_get_types('type', $node);
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
'#default_value' => $node->title,
'#weight' => -5
);
$form['xml'] = array(
'#type' => 'textarea',
'#title' => check_plain('xml'),
'#required' => TRUE,
'#weight' => -5
);
$form['xslt'] = array(
'#type' => 'textarea',
'#title' => check_plain('xslt'),
'#required' => TRUE,
'#weight' => -5
);
$form['body_filter']['body'] = array(
'#type' => 'textarea',
'#title' => check_plain($type->body_label),
'#default_value' => $node->body,
'#required' => FALSE
);
$form['body_filter']['filter'] = filter_form($node->format);
return $form;
}
So this brought me to the point that my content type comes up when creating new content - cool. But where do I need to go now to actually save my values? Where would I save my HTML once the XML is parsed on submit?
I know quite a few question, but any input would be great appreciated!
Thanks, Uwe