2

So this is strange. Template code:

{exp:channel:entries channel="[channel_name]"}

    {rich_text_field}

{/exp:channel:entries}

For the first entry, the text in the field will return wrapped with p tags. For the rest of the entries, all p tags are missing.

If I switch the field to a normal textarea instead, p-tags will be returned as excpected, for all entries.

I can find no errors anywhere in any logs, and template debugging returns nothing unusual.

The text renders correctly with p tags within the 'view code' part of RTE inside the control panel.

Oh, and this is the newest, 2.6.1 version of EE.

Any pointers where I can start looking for errors?

EDIT (more info): So the problem seems to be that the string ($this->text_format), during parsing, isn't marked as 'xhtml', but rather as 'none', and therefore isn't passed through to the auto_typography() method (I think it's somewhere in EE_typography.php, but I can't remember exactly). Again, this is only for the subsequent entries, and not the first.

3
  • 1
    If you add offset="1" (to remove the first entry returned) or if you change the sort order, is the result the same - first one has p tags and the others don't? May 15 '13 at 14:51
  • I haven't tried the offset, but reordering give same result - still the first entry in the loop that's correct.
    – megatrond
    May 15 '13 at 15:07
  • Did you find any workaround? I'm seeing the same issue.
    – philfreo
    May 21 '13 at 6:21
1

I've hacked core in order to fix this bug:

In system/expressionengine/modules/rte/ft.rte.php, find:

        array(
            'html_format'   => $this->row['channel_html_formatting'],
            'auto_links'    => $this->row['channel_auto_link_urls'],
            'allow_img_url' => $this->row['channel_allow_img_urls']
        )

Add this line in the array:

            'text_format'   => $this->row['field_ft_'.$this->field_id],

Feel free to report this bug with a link to this page.


Slightly related: I've also hacked this same method in order to avoid extra new lines to create empty <p> tags.

I changed:

ee()->functions->encode_ee_tags(ee()->typography->parse_file_paths($data))

to

ee()->functions->encode_ee_tags(trim(ee()->typography->parse_file_paths($data)))
1
  • This worked. Ellislab suggested the solution below, but this seems like a better solution as it queries the database for the proper text format. Also, thanks for the bonus solution to the extra newline problem, been looking for a way to fix that!
    – megatrond
    May 21 '13 at 9:17
2

There seems to be a suggested bugfix here.

It's also discussed here on Ellislab's support site.

Basically find this code (line 80 in system/expressionengine/modules/rte/ft.rte.php):

array(
    'html_format' => $this->row['channel_html_formatting'],

And replace with:

array(
    'text_format' => 'xhtml',
    'html_format' => $this->row['channel_html_formatting'],

I can confirm I had the same problem and this fixed it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.