The only way to do this is to change the $node->title
on the loaded object for the webform. That filename uses that title, so I am assuming you have a webform title of "Localhost Worklog".
The problem with that is you only want to change the node title, when you are downloading the webform (or atleast running through that process).
You have two options (I think). You could implement a hook_entity_load()
function and then check if the URL is
node/%webform_menu/webform-results/download or
node/%webform_menu/webform-results/download-file
function MYMODULE_entity_load($entities, $type) {
if (arg(2) == 'webform-results' && (arg(3) == 'download' || arg(3) == 'download-file')) {
foreach ($entities as $entity) {
$entity->title = $entity->title .'_'. now();
}
}
}
The other way I can think of is altering the page callback with a hook_menu_alter()
, changing the title there and then calling their function to return the form or download file with the updated node object to include the time appended to the title.
EDIT
From reviewing your update, it seems it's changing the title too soon on that page. So I think you will need a combo approach. Using hook_entity_load
and hook_form_alter
. The point is changing that title in the $node object that is passed around for download. So try this.
/*
* Implements hook_entity_load().
*/
function MYMODULE_entity_load($entities, $type) {
// Change the node title to include the time when downloading.
if (arg(2) == 'webform-results' && arg(3) == 'download-file') {
foreach ($entities as $entity) {
$entity->title = $entity->title .'_'. now();
}
}
}
/*
* Implements hook_form_alter().
*/
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == WEBFORM_DOWNLOAD_FORM_ID) {
// Change the node title that is passed around for download.
// @TODO: Check to make sure this is correct.
$form['node']['#value']->title = $form['node']['#value']->title . '_'. now();
}
}