Manually controlling the teaser break point

Last modified: August 15, 2008 - 09:47

Drupal has several ways of displaying nodes, e.g., Page view and Teaser view. In Page view Drupal displays the whole node, whereas in the Teaser view, only the Title and the Teaser are visible.

The teaser contains the first part of the body. By default Drupal's settings control where break between the teaser and the rest of the node occurs. It is possible, however, to set this manually using a special HTML comment tag.

Teaser settings (configured in Post settings) are global for all content created after the value is set. To change the teaser length of existing content, each node must be re-saved for the change to be reflected.

In order to manually set where the point for the teaser and remainder of the body to be split in a post, insert the tag <!--break--> where the teaser should end. Everything before this tag will appear in the teaser.

Note

Make sure there are no spaces in the tag or it will be ignored.

HTML block and span elements should not be divided by the <!--break--> tag as this may cause problems with the page layout and will produce invalid HTML markup. For this reason while the tag can be placed in the middle of a paragraph it is not advisable. The full text will not notice the tag so the paragraph will look normal, but the paragraph will be cut short in the teaser.

To prevent the block and span elements from being left open in the teaser display in Drupal 5.x using the contributed HTML corrector module can automatically close the tags. (In Drupal 6.x, this is part of Drupal core and is enabled by default.)

 
 

Drupal is a registered trademark of Dries Buytaert.