At present, nodewords doesn't pre-populate the form fields on a node which is being created as a translation from a source node. For example assume we have node/55, which is in english, and has Meta tags entered for description and Keywords. All good so far :)
If the (core) translation module is turned on, you get a "Translate" tab on node/55/edit. Click that and you can create a translation of node/55 into any other enabled language. If you do this for say German, you will get a node creation form which is pre-populated with the form field values of the original source translation (English). In other words, node 55's title, body, CCK fields etc are all carried over. However the node words are not.
This can be fixed by adding the following to nodewords.module at line 96:
<?php
// Deal with the special case, where this is an edit page for a new translation of a source node.
if (empty($node->nodewords)) {
$node = $form['#node']->translation_source;
}
Thus, the containing IF construct will look like:
<?php
if ($bool) {
$node = $form['#node'];
// Deal with the special case, where this is an edit page for a new translation of a source node.
if (empty($node->nodewords)) {
$node = $form['#node']->translation_source;
}
$form['nodewords'] = nodewords_form(
NODEWORDS_TYPE_NODE,
!empty($node->nodewords) ? $node->nodewords : array(),
array(
'page:permissions:additional' => 'administer nodes',
'tag_options' => array('node_type' => $form['type']['#value']),
)
);
}
Certainly my modification could be rewritten with better logic constructs, but I wanted my change to be as minimal as possible. Nonetheless you can see the idea, which is to get the ->nodewords from $node if it has them, otherwise try $node->translation_source.
Let me know if you would like a patch for this.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | nodewords_0961A001.patch | 821 bytes | avpaderno |
Comments
Comment #1
avpadernoThe correct way to proceed is to implement
hook_nodeapi("prepare translation"); only in that case$node->translation_sourceis available.Comment #2
avpadernoThis is the patch to apply to the development snapshot.
Comment #3
avpadernoThe code has been changed, and committed in CVS.
Thanks for your report.
Comment #4
jeff h commentedThanks for getting this in so quickly! I agree, nodeapi's "prepare translation" op is better.
Jeff