Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, I use [node:source:nid] tokens to generate automatic node titles in a multilanguage-web-site.
As long a node has already a translation, everything works fine.
But, if there is no translation, the node-title is empty.
Interesting part: Even if the "empty" token isn't part of the returned value, the node title is empty.
$var_pro = '';
$var_sourcenid = [node:source:nid]; 'breaks the node title when there is no translation
$var_lang = [node:language];
if ($var_lang == 'fr') {
$var_pro = 'Projet';
} elseif ($var_lang == 'en') {
$var_pro = 'Project';
} else {
$var_pro = 'Projekt';
}
$title = $var_pro . '#10';
return $title;
I tried to proof if the token exists (!empty ....) - but always the node title is empty. Can anyone help?
Comments
Comment #1
blattmann CreditAttribution: blattmann commentedDid you have any luck with this?
Comment #2
vistree CreditAttribution: vistree commentedI am sorry, but no ...
I think, the only chance is, to use php node load instead of tokens.
With php you can load the node and than proof variables like $node->language
Comment #3
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs for DrupalFit commented