I posted this on the forums - so you'll find all the background info at ( http://drupal.org/node/169259 ). I've been directed to post here. Sorry for the trouble.

It would be good to extend the <!--break--> comment to allow some extra html to be inserted for teasers so messy html can be properly closed in a teaser.

The proposed behavior is:

1) <!--break--> works as it did in 5.x. It serves as the marker for where to break the teaser.

2) <!--break extra stuff--> also serves as the marker for where to cut the teaser but "extra stuff" gets added to the end of the teaser.

So ugly markup that may need a table properly closed could:

<table>
<tr><td>lots of stuff</td><td>more stuff</td></tr>
<tr><td>lots of stuff</td><td>more stuff</td></tr>

<!--break </table>-->

<tr><td>lots of stuff</td><td>more stuff</td></tr>
<tr><td>lots of stuff</td><td>more stuff</td></tr>
</table>

Or you could even put the break right at the top of the node and completely put your own teaser in:

<!--break my own custom teaser goes here-->
All of the other page code goes here

To get this I changed the code in node.module - node_teaser. The code went from (note the &lt; is really supposed to be a < in the strpos() calls):

function node_teaser($body, $format = NULL) {

  [snip]

  // Find where the delimiter is in the body
  $delimiter = strpos($body, '&lt;!--break-->');

  [snip]

  // If a valid delimiter has been specified, use it to chop off the teaser.
  if ($delimiter !== FALSE) {
    return substr($body, 0, $delimiter);
  }

To:


function node_teaser($body, $format = NULL) {

  [snip]

  // Find where the delimiter is in the body
  $delimiter = strpos($body, '&lt;!--break');    // --- changed this

  [snip]

  // If a valid delimiter has been specified, use it to chop off the teaser.
  if ($delimiter !== FALSE) {
    $teaser = substr($body, 0, $delimiter);

    // Look for extra text/html in the comment and add that to the end of the teaser
    $delimiter_end = strpos($body, '-->', $delimiter);
    if ($delimiter_end !== FALSE)
    {
      $extra_start = $delimiter + 9;
      $extra_length = $delimiter_end - $extra_start;
      $teaser_close = substr($body, $extra_start, $extra_length);
      $teaser = $teaser.$teaser_close;
    }
    return $teaser;
  }

So long as current users are using the break as it was intended this changed shouldn't affect them.

Comments

gpk’s picture

Version: 7.x-dev » 6.x-dev
Status: Active » Fixed

This proposed feature is no longer needed as of Drupal 6 since, if it is active, the HTML corrector filter will automatically close any elements left open in the teaser.

Pls reopen if you find you still can't get the behaviour you want in D6.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.