I'm not sure if this is a mail_edit issue or date or subscriptions issue I was advised to post this here.

I go to administer->site building->mail templates and configure the digest template to include a cck date created using the date module.

When the date is printed in the digest email, it contains HTML tags, even though the user's account is configured to receive e-mail in plain text only:

Title: MPAA: Box Office Up 5.2%, Foreign Ticket Sales Dominate
<span class="date-display-single">04/01/2009</span>

TheWrap.com : Foreign now comprises 65 percent of the industry total -- an
increase of 17 percent over the last five years.

I uninstalled mimemail, but the date is still wrapped in these tags. Any ideas on how to remove these tags from the date printed in the digest?

I posted this in the subscriptions issue forum and got this reply:

#1
salvis - April 3, 2009 - 00:18

You mean a cck date field?

subscriptions_cck.module uses the following code

          if (!($formatted = html_entity_decode( content_format($field_info, $value, 'plain'), ENT_QUOTES, 'UTF-8'))) {
            $formatted = content_format($field_info, $value, 'default');
          }

to try to retrieve the field data in 'plain' format. If nothing is returned, it then asks for the 'default' format. Please take this information to the queue of the cck module that supplies your date field and ask there, why you're getting the span tags.

CommentFileSizeAuthor
#13 423502-13.patch4.73 KBroderik
#7 423502-7.patch5.07 KBroderik
#6 423502-6.patch5.14 KBroderik

Comments

karens’s picture

Title: HTML "span" tags on date tokens even when MimeMail is not installed » Add plain format without any HTML
Category: bug » feature

There is no 'plain' format, but there probably should be one, so this is a feature request. Shouldn't be hard to add, I just need to get to it.

But on the mime mail issue, I don't know why they don't just do strip_tags() on the value they get back for plain mail text, I would guess that many or most CCK 'default' values have html in them.

aren cambre’s picture

I also need this for data exports. Right now my XML export (through Views Bonus Pack) looks like this on a module's date field named Date:
<Date>&lt;span class="date-display-single"&gt;Tue, 06/16/2009&lt;/span&gt;</Date>.

Excel's gonna barf when it sees this.

I could give the fix a shot if you can guide me where to find the code.

aren cambre’s picture

Karen, if you get a chance, could you review #495426: Doesn't respect Format of overridden Date module in Views Bonus Pack's queue and see whether it relates to this?

Andrew Kaufmann’s picture

Hey Karen!

I'm doing a large amount of XML export as well, and the ability to have the date in a plain format is also important to me -- and others, based on the thread referenced in #3.

Any chance of seeing that feature added?

Thanks!

Andrew

bomarmonk’s picture

roderik’s picture

StatusFileSize
new5.14 KB

OK, here's a patch.

It adds extra formats: for every format 'Long', 'Medium', 'Short' & custom defined formats, there is an extra format:
- the format string has '_plain' appended
- the description has ' (no HTML)' appended.
Also, a 'default_plain' format is added, which could be used (instead of 'plain') in the code block in the original post.

This patch theoretically can change the behavior of some custom defined formats, because date_formatter_process() assumes that all field formats ending in '_plain' are a plaintext companion of a field format with '_plain' chopped off.

roderik’s picture

StatusFileSize
new5.07 KB

Meh. I'm getting warnings from strrpos sometimes, saying the index is out of bounds for the haystack.

Here's a fixed patch, where the comparisons using 'strrpos' are replaced by 'substr', which does not have that problem. (And is better readable too.)

roderik’s picture

Status: Active » Needs review

Forgot status change

Renee S’s picture

Can I suggest calling it "plain" and label it "Plain text" to make it consistent with the core formatters?

brad.bulger’s picture

this is working for me. i have a related question that i may need to take to the Views queue, though: the output in a view of a date field in the Plain format has a whole bunch of white space and newlines before and after the value. where are those coming from? they don't seem to be coming out of the Date code.... this was a Views issue, not related to the plain date formatting.

rbrownell’s picture

+1 Subscribe

Any further progress on this?

roderik’s picture

Well, people (which in busy project queues are usually not the module maintainer) usually try the patch out and comment, or set it to RTBC.

I don't feel qualified to decide on the labeling issue, or on naming the default plaintext format 'plain' instead of 'default_plain'.
I'm sympathetic to labeling the formats "formatname (plain text)" instead of "formatname (no HTML)" as I did... just not sure if people would grasp what the non-'plain text' format was, in that case.

roderik’s picture

Version: 6.x-2.x-dev » 6.x-2.7
StatusFileSize
new4.73 KB

re-roll

marcoscano’s picture

is this patch going to be ported (or committed) to D7? I'm having the same issue with date 7.x-2.x-dev

thanks

honza pobořil’s picture

Component: Date CCK Field » Code

In D7 it is already solved - use "plain" formatter for date fields.

damienmckenna’s picture

Status: Needs review » Closed (won't fix)

Unfortunately the D6 version of this module is no longer supported, but we appreciate the time you put into this. If this problem is relevant for D7 too, please reopen the issue. Thanks.