Translatable Batch Actions - hack

Translatable Batch Actions - yep, a hack...

Problem
When Translatable is enabled in SilverStripe, Batch Actions won't work on secondary languages.

Reason
Batch Actions fail to include the current site locale in any URL they call - neither in a GET nor in a POST parameter. That means SilverStripe will always revert to the default en_US locale and DataObject::get() will never find any pages in a secunday language when it filters on the default locale...

Fix
Find a way to add the right locale. There are two files involved in what is in fact a hack, and could maybe be a bugfix, when it proves to be solid. For now a simple hack beats publishing hundreds of pages by hand. So far it works fine for me (v2.4.5), but anyone encountering weird things, please let me know. 

1.  /cms/templates/includes/CMSMain_left.ss

Find the form with id="batchactionsforms" (around line 69) and add a new hidden field for the locale. Save, and do a ?flush=1

<form class="actionparams" style="border:0" id="batchactions_options" action="">
	$BatchActionParameters

	...

	<input type="hidden" name="locale" id='batchactions_options_locale' value="$Locale" />

2. /cms/javascript/CMSMain_left.js

Find the following line of code (around line 461):

var applicablePagesURL = $('choose_batch_action').value + '/applicablepages?csvIDs=' + ids.join(',');

And add the locale to the end of the URL:

var applicablePagesURL = $('choose_batch_action').value + '/applicablepages?csvIDs=' + ids.join(',') + "&locale=" + $('batchactions_options_locale').value;

That should do it...

Comments

Het versturen van reacties is uitgeschakeld.

RSS feed voor reacties op deze pagina