Token in Node wird nicht ersetzt
am 24.06.2010 - 13:50 Uhr in
Wie der Titel schon sagt hab ich etwas Probleme mit dem Token Modul. Ich schreibe grade ein neues Modul auf der Basis des Token Moduls. Das habe ich momentan.
function mymod_token_values($type, $object = NULL, $options = array()) {
$tokens['blubb'] = "Das ist sehr gut";
return $tokens;
}
function mymod_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if($op=="view")
{
$node->body = token_replace($node->body, $type = 'global',NULL,'[',']');
}
}Im Node habe ich [blubb] stehen. Das wird aber nicht ersetzt bei der Ausgabe. Ich glaube dass die funktion token_replace irgendwie falsch ist, bzw. der type parameter oder so ? Bin aber nicht sicher, ...
- Anmelden oder Registrieren um Kommentare zu schreiben

habs ...
am 29.06.2010 - 08:49 Uhr
Hab die Lösung mal wieder selbst gefunden :-) ... das hatte ich:
function mymod_token_values($type, $object = NULL, $options = array()) {
$tokens['blubb'] = "Das ist sehr gut";
return $tokens;
}
function mymod_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if($op=="view")
{
$node->body = token_replace($node->body, $type = 'global',NULL,'[',']');
}
}
aber $node->body wird garnicht ausgegeben. Ich hab mir mal das Object mit print_r ausgegeben und gesehen es muss $node->content['body']['#value'] heissen. Also der Code müsste so aussehen:
function mymod_token_values($type, $object = NULL, $options = array()) {
$tokens['blubb'] = "Das ist sehr gut";
return $tokens;
}
function mymod_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if($op=="view")
{
$node->content['body']['#value'] = token_replace($node->content['body']['#value'], $type = 'global',NULL,'[',']');
}
}
Evtl. hilft das anderen mit einem ähnlichen Problem weiter...