I was going to post something with Crumbs, but maybe you can start with something simpler:
I am trying to make this answer useful to different visitors who might have different ideas about their breadcrumb for webform submission pages.
Page access considerations
Do your visitors (those this is meant for) have access to pages like
- node/28/submission/1/edit ? (I suppose the answer is yes)
- node/28/submission/1 ? (Please check)
With hook_menu_alter()
I'm not sure what this does on a site without Crumbs enabled, but you can give it a try. This will change the page title / navigation title, which I think is used by core for building the breadcrumb.
This means if you had "Submission #1" as part of your breadcrumb, this will replace it with "Submission #2 by NAME".
Consider this code a stub. Especially the $submission->data[1][0]
. This just happened to work for me, but might be different for you. devel dpm() is your friend!
/**
* @param array[] $items
*/
function d7light_menu_alter(&$items) {
if (!empty($items['node/%webform_menu/submission/%webform_menu_submission'])) {
/* @see _d7light_webform_submission_title() */
$items['node/%webform_menu/submission/%webform_menu_submission']['title callback'] = '_d7light_webform_submission_title';
}
}
/**
* @param object $node
* @param object $submission
*
* @return string
*
* @see webform_submission_title()
*/
function _d7light_webform_submission_title($node, $submission) {
if (empty($submission->data[1][0])) {
return t('Submission #@serial', array('@serial' => $submission->serial));
}
return t(
'Submission #@serial by @name',
array(
'@serial' => $submission->serial,
// @todo Maybe something more generic than ->data[1][0]?
'@name' => $submission->data[1][0],
));
}
With Easy Breadcrumb + hook_menu_alter()
Tbh I have only tested the code above with Crumbs enabled. So I don't know if it works without it.
I am also quite confident that it will work with Easy Breadcrumb, based on my understanding how it works.
With Crumbs + hook_menu_alter()
As said: You could try if enabling Crumbs makes a difference.
If you do, you might want to check admin/structure/crumbs/display and enable the "show current page".
With the Crumbs API.
This is an alternative to the method above, which does not change the page title but only the name in the breadcrumb.
Here is a starting point.
/**
* A hook to register crumbs plugins.
*
* @param crumbs_InjectedAPI_hookCrumbsPlugins $api
* An object with methods to register plugins.
* See the class definition of crumbs_InjectedAPI_hookCrumbsPlugins, which
* methods are available.
*/
function MYMODULE_crumbs_plugins($api) {
$api->routeTitleCallback(
'node/%/submission/%',
'webform_submission',
function($path, array $item) {
$node = $item['map'][1];
$submission = $item['map'][3];
if (0
|| !is_object($node)
|| !is_object($submission)
|| $node->type !== 'webform'
|| empty($submission->data[1][0])
) {
return NULL;
}
$submission_name = $submission->data[1][0];
return $item['title'] . ' (' . check_plain($submission_name) . ')';
});
}
The same comment applies about $submission->data[1][0]
.
Changing the trail
Once you have tried those things, you can ask if you need more. I will then write more in this section.
Home>webform>Name
, right? Or that Name is dynamic, means that Name has to be replaced by the USer name.