Using the Drupal teaser break with filtered HTML in Drupal 7

A quick Drupal 7 tip for anyone trying to use the Drupal teaser break (<!--break-->) with an input format other than full HTML: to ensure that the teaser break is observed HTML comments need to be included in the allowed HTML tags so that they are not filtered out of the content. You can do this by adding <!--> to the allowed tags of your input format (Configuration > Text formats).

Drupal 7

Once this is in place whenever the "teaser" display is used only content upto the teaser break will be output and Drupal will include the standard "read more" link to the node.

Related Content

Published on


Comments

  1. wagaf |

    You just saved me hours of searches and useless coding. Thanks.

    Sometimes Drupal has so many ways to do the same thing (here cleaning HTML) that it becomes difficult to debug a site.

  2. Andy |

    Glad it helped wagaf.

  3. john ludd |

    Thank you so much!
    you saved my day!

  4. Chrys Ostrander |

    The teaser break in the source causes a line break in the text in view mode. Any ideas why that would be?

  5. Andy |

    @Chrys, sorry can’t be much help. To be honest I’ve not worked with Drupal for a couple of years due to a change in work.

  6. Mohammed |

    You just saved me hours of searches and useless coding.

  7. Al Reaud |

    In Drupal 8.1.8, I was having the problem of line breaking in view mode. Firebug indicated that it was converting the break to a paragraph. What I did was go to “Home—>Administration—>Configuration—>Content authoring—>Text formats and editors” and unckeck “Convert line breaks into HTML (i.e. <br> and <p>)” That resolved the problem. Hope this helps!

Leave a Comment
  • You will need to preview your comment before you can submit it.