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.

CommentFileSizeAuthor
#2 nodewords_0961A001.patch821 bytesavpaderno

Comments

avpaderno’s picture

The correct way to proceed is to implement hook_nodeapi("prepare translation"); only in that case $node->translation_source is available.

avpaderno’s picture

StatusFileSize
new821 bytes

This is the patch to apply to the development snapshot.

avpaderno’s picture

Version: 6.x-1.5 » 6.x-1.x-dev
Status: Active » Fixed

The code has been changed, and committed in CVS.

Thanks for your report.

jeff h’s picture

Thanks for getting this in so quickly! I agree, nodeapi's "prepare translation" op is better.

Jeff

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.