I suggest to add a small feature, to allow syncing the 'created' field (post date).

My use case: a multilingual portfolio of projects should be sorted by date identically in each language.

I simply added the following option:
'created' => t('Post date'), around line 472 in i18nsync.module

It's also a very simple patch, attached.

Comments

Stefano’s picture

I was looking just in this feature, as I have the same problem of having the same sorting order.
I did the code change as suggested here but this doesn't seem to work.
When I create a new translation for a node the 'created' date of the Sourcee isn't loaded in the "authored on" field.
I have tried to follow the code of the module but I'm not experienced in Drupal codes so I can't understand why this doesn't work.
If anyone can help I'd really appreciate.

Thank you in advance.

Anonymous’s picture

Have you also ticked the checkbox at the content type's multilingual settings? You need to select "changed" or "published" (whichever one it is). Then it should work.

Stefano’s picture

Priority: Minor » Normal

Yes I have. Or better, I have checked the "Post Date" checkbox, it's the one that was added applying the patch above.

I have tested a bit with what's happening in the module. If I have understood right how that works the function responsible for loading the right value upon creation of the translation is 'i18nsync_prepare_translation'. I have echoed some values in the function and it seems that it behaves correctly, it copies the "created" value (the timestamp) from the source to the new node, but somehow it doesn't get set in the HTML. On the contrary it's the Source's "created" date that gets modified to the current date. Maybe Drupal forces the "created" form field to be empty when a node is created.

If I change the "created" value of one node it gets correctly changed on the other nodes too, so this works ok; it's just the creation process that doesn't work.

Please, if you can find a solution to this tell me. It's the last thing I need to complete the new version of my website ^^

Stefano’s picture

Status: Active » Needs review

After some time spent tring to understand where Drupal was ignoring the 'created' field I've found how to make this feature work correctly.
The solution came while reading the how the node_form function works. This is the function that defines those form fields and look at the point where it defines the 'created' field it is clear that a default_value for that field is not defined if $node->date is not set so the only thing do to was setting this variable (with a formatted date, not with the timestamp).

I'm sorry if I don't create a patch....but I have no idea how to make one XD
What is required to make this all work is a little add to the function i18nsync_prepare_translation (in addition to the patch posted above, of course):

/**
 * Prepare node translation. Copy over sincronizable fields.
 */
function i18nsync_prepare_translation(&$node, $source, $field_list) {
  foreach ($field_list as $field) {
    if (empty($source->$field)) continue;
    switch ($field) {
      case 'taxonomy':
        // Do nothing, this is handled by the i18ntaxonomy module
        break;
      case 'created':
        $node->date = format_date($source->created, 'custom', 'Y-m-d H:i:s O');
      default:
        $node->$field = $source->$field;
        break;
    }
  }
}
rup3rt’s picture

+1 For this -- essential for any content that is date dependent

jose reyero’s picture

Status: Needs review » Active

No working patch that I can see.

lmeurs’s picture

Title: Allow syncing post date » Almost a patch!
Version: 6.x-1.2 » 7.x-1.1
StatusFileSize
new1.85 KB

Unfortunately I also do not have a patch (I'm still learning!), but hopefully this will help for v7.x-1.1 (latest) of i18n/i18n_sync/i18n_sync.modules.inc. Also see attachment (which has a .txt extention for uploading reasons).

On line 58 we only added the 'created' element.

function node_i18n_sync_options($entity_type, $bundle_name) {
  if ($entity_type == 'node') {
    return array(
      'uid' => array('title' => t('Author')),
      'status' => array('title' => t('Status')),
+      'created' => array('title' => t('Creation date')),
      'promote' => array('title' => t('Promote')),
      'moderate' =>  array('title' => t('Moderate')),
      'sticky' => array('title' => t('Sticky')),
      'revision' =>  array('title' => t('Revision'), 'description' => t('Create also new revision for translations')),
    );
  }
}
lmeurs’s picture

Title: Almost a patch! » Allow syncing post date

(I accidentally changed the thread's title and had to post another comment to revert the change)

tunic’s picture

Status: Active » Needs review
StatusFileSize
new2.13 KB

Patch attachted. Tested on 1.0 (I'm sorry, I'm stuck at this version for some reasons at the moment) but patched ported to 7.x-1.x (code has not changed, at least the one that sourrounds what I've changed).

Patch is based on previous notes, but... mmm... line numbers and file names from previous comments do not match with i18n_sync module...

Status: Needs review » Needs work

The last submitted patch, i18n-sync_post_date-706462-9.patch, failed testing.

tunic’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Needs work » Needs review

Ooops!

Changing version, I hope this is why it fails.

tunic’s picture

#9: i18n-sync_post_date-706462-9.patch queued for re-testing.

jose reyero’s picture

Status: Needs review » Fixed

Committed, thanks.

Status: Fixed » Closed (fixed)

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

j0rd’s picture

Version: 7.x-1.x-dev » 6.x-1.10

I need this feature backported to 6.x as well.

j0rd’s picture

Version: 6.x-1.10 » 6.x-1.x-dev
Status: Closed (fixed) » Needs review
StatusFileSize
new450 bytes

Patch against 6.x-1.x-dev

Status: Needs review » Needs work

The last submitted patch, i18n-sync_post_date-6.x-706462-16.patch, failed testing.

joseph.olstad’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)