I am using the auto_nodetitle module to build a node title from the value of another CCK field. I am using PHP code to create the actual title, and ran into an interesting problem: how do I reference the token value when the string might contain both single AND double quotes? '[token]' and/or "[token]" might produce parser errors.

Wondering if you have any comments about how you would approach this. The workaround I ended up using was heredoc syntax:

$var = <<<EOT
[token]
EOT;

which is really weird to type into a textbox but does seem to work nonetheless...

Thanks

Comments

jsenich’s picture

I am running into the same problem right now, but the heredoc syntax workaround doesn't seem to be working for me.

mikeker’s picture

(Apologies for resurrecting this thread, but I found tatere's original post very helpful. Thank you for posting your solution!)

Jsenich: This workaround works great for me in D6. Without seeing your code, it's hard to help, but one common problem is forgetting to returning your variable at then end of your snippet. Eg:

$title = <<< END_TITLE
[field_alt_title-raw]
END_TITLE;
return $title;

Hope that helps.

dave reid’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.