I suggest copy/pasting the serialized array from the site_pages
column and using an online generator to unserialize it. Then copy the unserialized array over to a text editor to find/replace the old template_id
with the new the template_id
.
The array contains a URI array & Template array. The template array is the last array. So look for [1] => 4
which is [entry_id] => template_id
I would do a find and replace just for template_id
: => 5
to => XX
As far as serializing the array, I haven't found a online generator to make it easy. You may just need to create a template and enable PHP to serialize it for you, then copy/paste it back into the site_pages
column.
Always backup first!
Update
I just found this script to batch update entries.
2nd Update
Added the two lines of code for the updating the old template id with the new. Should save a couple clicks
<?php
/**
* Batch reset template_id for Structure entries
*/
$str = base64_decode("PASTE-VALUE-FROM_site_pages_FIELD-HERE");
$arr = unserialize ($str);
$old_template_id = PASTE-OLD-TEMPLATE-ID-HERE; //e.g. 3;
$new_template_id = PASTE-NEW-TEPLATE-ID-HERE;//e.g. 24;
// Set new template_id
foreach( $arr[1]['templates'] as $key => $template_id )
{
if ($template_id == $old_template_id)
$arr[1]['templates'][$key] = $new_template_id;
}
// Output
print '<pre>';
print_r($arr);
print '</pre>';
// Serialize & encode
$new_arr = serialize($arr);
$new_str = base64_encode($new_arr);
// Output for copy/paste
print "<textarea rows='100' cols='80'>";
print $new_str;
print "</textarea>";
exit;
?>