TASK:
I have node types: typical, subtypical.
Need for creating a page subtypical make for it clone nodes in all languages of site,
and then make for each path alias like
www.site.com/typical/subtypical - for default lang
www.site.com/en/typical/subtypical - for other
SOLUTION:
I create menu for each language. And add all typical and subtypical in those menus.
Path alias i make with pattern [menupath-raw].html
For node clone, i make rule in Rules module:
After saving new content
IF Created content is Subtypical
DO Execute custom PHP code
And in code i include php file
<?php
// $node->promote = 1 | 0; use as my publish\unpublish
$node->tnid = $node->nid;
$_node = new stdClass();
$_node = drupal_clone($node);
$node->promote = 1;
node_save($node);
// Delete unique params
unset($_node->nid);
unset($_node->vid);
// Get menu parent id from format menu-logical-ru:652 where «menu-logical-ru» and 652 is id of parent menu(not node id)
$def_lang_plid = substr($node->menu['parent'],16);
// Take parrent menu node->nid from link_path (stored in format «node/%»)
$def_parrent_nid = substr(db_result(db_query("SELECT link_path FROM menu_links WHERE mlid = '$def_lang_plid'")),5);
// Take parrent node->tnid
$def_parrent_tnid = db_result(db_query("SELECT tnid FROM node WHERE nid = '$def_parrent_nid'"));
// Take list of languages except our node->langeage
$languages = language_list('enabled');
unset($languages[1][$node->language]);
foreach ($languages[1] as $langcode => $language) {
//select parrent node nid in this language
$pnid = db_result(db_query("SELECT nid FROM node WHERE language = '$langcode' AND tnid = '$def_parrent_tnid'"));
//select parrent MENU id in this language
$plid = db_result(db_query("SELECT mlid FROM menu_links WHERE link_path = 'node/$pnid'"));
$tnode = drupal_clone($_node);
$tnode->language = $langcode;
$tnode->menu['menu_name'] = "menu-logical-$langcode";
$tnode->menu['parent'] = "menu-logical-$langcode:$plid";
$tnode->menu['plid'] = $plid;
$tnode->menu['mlid'] = 0;
$tnode->menu['language'] = $tnode->language;
if (empty($tnode->menu['link_title']))
$tnode->menu['link_title'] = $node->title;
node_save($tnode);
//todo -c pathauto: need update path aliath for tnodes !!!
unset($tnode);
}
node_save($node);
MY PROBLEM:
Not created path alias for the languages for which the node cloned.
In admin Content » List If i choose «Update URL alias» it work. I try to use functions pathauto.module but without result
Comments
Comment #1
Dave ReidWe don't support creating multiple aliases for the same page.