I'm getting output like this in my title from CCK fields: <p>Mozart</p> , <p>Wolfgang</p> (<span class="date-display-single">1 January, 2007</span>-<span class="date-display-single">1 J

Drupal 5-1
CCK, Automatic Nodetitles, Token modules all checked out with DRUPAL-5.

// $Id: token.module,v 1.5.2.3 2007/01/28 19:41:59 eaton Exp $
// $Id: auto_nodetitle.module,v 1.4.2.4 2007/01/13 20:06:09 fago Exp $
// $Id: content.module,v 1.90.2.36 2007/01/29 16:03:43 yched Exp $

Comments

robertdouglass’s picture

Tokens I am using: [field_last_name], [field_first_names] ([field_birth_date]-[field_death_date])

field_last_name = text (single)
field_first_names = text (multiple)
field_birth_date and field_death_date = date fields (CCK)

eaton’s picture

Modules that need to to tag-stripping need to perform some extra processing on the token values they get from token.module. There's an example of how to do that in token.module's API.txt, if there's demand I might add an option for it (check_plain processing of replacement values, etc) to the core module.

robertdouglass’s picture

Status: Active » Needs review
StatusFileSize
new691 bytes

Easy enough to fix.

robertdouglass’s picture

StatusFileSize
new1.39 KB

check_plain is better.

This patch also addresses a separate bug (fago, if you need me to I'll open up another issue):

on the admin/content/types/{type}/fields page (Administer->Content management->Content types->edit->Manage Fields), the auto_nodetitle module thinks we are editing a node and thus tries to set the title (resulting in array_merge errors). This patch adds an extra check that clears this up. It's a bit hackish, so give it some thought to see if it could be better.

ray007’s picture

not sure what went wrong (patch complained about having to use '-R'), but my new title now is:
&lt;span class=&quot;date-display-single&quot;&gt;Monday, 1. January 2007&lt;/span&gt;

robertdouglass’s picture

thanks for reviewing. I submitted and then realized how stupid check_plain is. I'm working on a different version.

ray007’s picture

Maybe strip_tags() instead of check_plain() ?
And my last result seemed like a double-encoding, maybe we also need to reverse some check_plain() that happened before auto_nodetitle got it's hands on the data with htmlspecialchars_decode()?

robertdouglass’s picture

StatusFileSize
new1.43 KB

Well here is a patch the produces the correct results. strip_tags wasn't enough... I had to preg_replace out all line endings, carriage returns, tabs and so forth.

Some coordination is going to be needed with token.module on this, though. Wherever the line breaks are coming from, they're unwanted.

ray007’s picture

yes! thanx, that works now.

btw: which version did you base your patch on? when applying, patch always complains

patching file auto_nodetitle.module
Reversed (or previously applied) patch detected!  Assume -R? [n]

after answering "n" i get a second question
Apply anyway? [n]
to which I answer "y", and than it works, I only get a one-hunk-reject on the id-line ...

now back to my basic problem of getting the wrong date, which is another topic ;-)

dodorama’s picture

I think this patch belongs to the token module as stated here.

fago’s picture

Status: Needs review » Fixed

thanks robert, patch committed to 5.x and HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)