I managed it now like this in a custom module.
What I do is add a new argument to the system path, so
node/<nid>
becomes node/<nid>/<slide_num>
Can it be made better?
/**
* implements hook_pathauto_alias_alter()
* alters the alias of a newly created slideshow node
*/
function coco_slideshow_pathauto_alias_alter(&$alias, &$context) {
// print_r(array($alias, $context));
if ($context['module'] == 'node' && $context['type'] == 'slideshow'
&& ($context['op'] == 'insert'
|| $context['op'] == 'update')
) {
$node = $context['data']['node'];
module_load_include('inc', 'pathauto');
module_load_include('inc', 'path');
// get default path alias from patterns
// this will be start of url alias
$pattern = pathauto_pattern_load_by_entity('node', $node->type, $node->language);
$path = pathauto_clean_alias(token_replace($pattern, array(
'node' => $node,
), array(
'sanitize' => false,
'clear' => FALSE,
'callback' => 'pathauto_clean_token_values',
'language' => (object) array('language' => $node->language),
'pathauto' => TRUE,
)));
$pages = field_get_items('node', $node, 'field_pages');
if (!empty($pages)) {
$slide_id = $pages[0]['value'];
$slide = field_collection_item_load($slide_id);
if (!empty($slide)) {
$headline = field_get_items('field_collection_item', $slide, 'field_slide_headline');
$headline_text = $headline[0]['safe_value'];
if (!empty($headline)) {
$path_text = pathauto_cleanstring("{$headline_text} {$slide_id}");
// alias is replaced with new one
$alias = "{$path}-{$path_text}";
}
}
}
}
}
/**
* implements hook_node_insert()
*
* creates aliases for each slide in slideshow node type
*/
function coco_slideshow_node_insert($node) {
if ($node->type == 'slideshow') {
module_load_include('inc', 'pathauto');
module_load_include('inc', 'path');
$title = $node->title;
$nid = $node->nid;
// get default path alias from patterns
// this will be start of url alias
$pattern = pathauto_pattern_load_by_entity('node', $node->type, $node->language);
$path = pathauto_clean_alias(token_replace($pattern, array(
'node' => $node,
), array(
'sanitize' => TRUE,
'clear' => TRUE,
'callback' => 'pathauto_clean_token_values',
'language' => (object) array('language' => $node->language),
'pathauto' => TRUE,
)));
$pages = field_get_items('node', $node, 'field_pages');
if (!empty($pages)) {
$slides = field_collection_item_load_multiple($pages);
if (!empty($slides)) {
$i=0;
foreach ($slides as $slide_id => $slide) {
$headline = field_get_items('field_collection_item', $slide, 'field_slide_headline');
if (!empty($headline)) {
$headline_text = $headline[0]['safe_value'];
// create clean string for pathauto for every single slide
// this will be second part of url alias
$path_text = pathauto_cleanstring("{$headline_text} {$slide_id}");
// first slide should alias to node/<nid>
// not to node/<nid>/<slide_id>
// this is handled in hook_pathauto_alias_alter
if ($i > 0) {
$save = array(
'source' => "node/{$nid}/{$i}",
'alias' => "{$path}-{$path_text}",
'language' => $node->language,
);
path_save($save);
}
}
$i++;
}
}
}
}
}
/**
* implements hook_node_update
*/
function coco_slideshow_node_update($node) {
if ($node->type == 'slideshow') {
module_load_include('inc', 'pathauto');
module_load_include('inc', 'path');
$title = $node->title;
$nid = $node->nid;
// get default path alias from patterns
// this will be start of url alias
$pattern = pathauto_pattern_load_by_entity('node', $node->type, $node->language);
$path = pathauto_clean_alias(token_replace($pattern, array(
'node' => $node,
), array(
'sanitize' => TRUE,
'clear' => TRUE,
'callback' => 'pathauto_clean_token_values',
'language' => (object) array('language' => $node->language),
'pathauto' => TRUE,
)));
$pages = field_get_items('node', $node, 'field_pages');
if (!empty($pages)) {
$slides = field_collection_item_load_multiple($pages);
if (!empty($slides)) {
$i=0;
foreach ($slides as $slide_id => $slide) {
$headline = field_get_items('field_collection_item', $slide, 'field_slide_headline');
if (!empty($headline)) {
$headline_text = $headline[0]['safe_value'];
// create clean string for pathauto for every single slide
// this will be second part of url alias
$path_text = pathauto_cleanstring("{$headline_text} {$slide_id}");
// first slide should alias to node/<nid>
// not to node/<nid>/<slide_id>
// this is handled in hook_pathauto_alias_alter
if ($i == 0) {
$save = array(
'source' => "node/{$nid}",
'alias' => "{$path}-{$path_text}",
'language' => $node->language,
);
$temp = drupal_get_path_alias("node/{$nid}", $node->language);
path_delete(array('alias' => $temp));
// print '<xmp>' . print_r($save,1). '</xmp>';
path_save($save);
} else {
$save = array(
'source' => "node/{$nid}/{$i}",
'alias' => "{$path}-{$path_text}",
'language' => $node->language,
);
path_delete(array('source' => "node/{$nid}/{$id}"));
path_save($save);
}
}
$i++;
}
}
}
}
}