Somewhere in the documentation I read where I can insert a tag (like <break /&gt:) to indicate where to break the content between the introduction, and the remaining body text. Now I've searched everywhere, and even looked thru the code, and I can find it. Can someone help?

Comments

David Hull’s picture

The delimiter that node.module uses to indicate the end of the teaser text is &lt;!--break--&gt;.

sandip-1’s picture

I wonder if it is possible to break up a node into teasers and main body OPTIONALLY. I mean I would normally want the complete content to be visible on the front page regardless of its length. So I normally have to keep teasers disabled. However, in certain articles, I would like only the teaser to show.

So even if I have teasers disabled, is it possible to still break up my stories into teasers if I use &lt;!--break--&gt; ?

--
Sandip Bhattacharya
http://www.sandipb.net

Kobus’s picture

I have implemented it as such on my site www.humourauthority.com:



1) Edit node.module, find this code:


<code>
  $delimiter = strpos($body, "<!--break-->");
  if ($delimiter > 0) {
    return substr($body, 0, $delimiter);
  }


The default setup of node.module is to

  • Find if teasers are enabled, if so, return the body.
  • Checks the size of the body, and if it's a short body (shorter than the size specified in the configuration, return the entire body.
  • Checks for the delimiter <!--break-->, and then cut the post off there.

What I've done is to change the order of the last two choices by swapping out the code, and now the order is as follows on my site:

  • Find if teasers are enabled, if so, return the body.
  • Checks for the delimiter <!--break-->, and then cut the post off there.
  • Checks the size of the body, and if it's a short body (shorter than the size specified in the configuration, return the entire body.

My site is now set up to the default of 600 characters for trimming posts, but as it looks for the delimiter *before* the size is taken into account, it works perfect for me.



The only problem this approach has is that if you want to display the entire body of the text, your text must end with the delimiter after the text, otherwise a few minor problems occurs:

  • The text will be cut at the 600 character limit, as the delimiter is not found. Adding the delimiter is no problem for me though - it's simply about getting into a habit of ending all posts with <!--break-->
  • I have at some stage during modifying node.module got the problem of the warning message "delimiter not found" or something alike, and adding the delimiter at the end of the post prevented that problem.

Hope this helps.



Kobus

ijulie’s picture

This sounds like a great little hack, and I'd like to try it. But for those of us who aren't php inclined, could you give the new code, after your alteration?

rufferto@mac.com’s picture

Actually wouldn't making teasers totally optional solve the problem of having to add the <!--break--> at the end of posts?

In other words:

  • Checks for the delimiter <!--break-->, and then return the cut off post, OR
  • Find if teasers are enabled, if so, return the body.
  • Checks the size of the body, and if it's a short body (shorter than the size specified in the configuration, return the entire body.

I haven't actually examined the code but you get the idea I hope.

This is what I would like to see implemented.

varunvnair’s picture

This should do the trick:

Go to administer >> content >> configure >> length of trimmed posts

and set Length of trimmed posts to Unlimited

Now by default the entire body of your posts will appear on the front page. If you want to cut it off at a certain place just add <!--break-->

My Drupal-powered Blog: ThoughtfulChaos - Varun's Blog