Closed (fixed)
Project:
File (Field) Paths
Version:
6.x-1.x-dev
Component:
Code
Priority:
Minor
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
27 Dec 2009 at 14:16 UTC
Updated:
31 Dec 2009 at 01:42 UTC
Hi,
I tried to save my images using this module with the node Title token. Result was great, as expected, only the images in translated nodes would be renamed twice and end up with the less desirable second language title.
I solved it for now by making an extra token which always represents the untranslated title. Put it here for it might help somebody else.
/**
* Implementation of hook_token_values().
*/
function mymodule_token_values($type, $object = NULL, $options = array()) {
if ($type == 'node') {
$tokens = array();
if ($object->tnid != $object->nid && $object->tnid != 0) {
$node = node_load($object->tnid);
$tokens['untranslated_title'] = $node->title;
}
else {
$tokens['untranslated_title'] = $object->title;
}
return $tokens;
}
}
/**
* Implementation of hook_token_list().
*/
function mymodule_token_list($type = 'all') {
if ($type == 'node' || $type == 'all') {
$tokens = array();
$tokens['node']['untranslated_title'] = t("The node's original, untranslated title.");
return $tokens;
}
}
Comments
Comment #1
decipheredHi splash112,
Thanks for the code snippet, hopefully it helps someone in the future.
You might also consider Custom Tokens as an alternative to writing a custom module, but if you already had the custom module then there's no harm.
I have marked the topic as closed as I didn't know how else to handle this sort of issue, but that shouldn't effect people being able to find the issue through search.
Cheers,
Deciphered.