Just set the teaser length as 200 characters @ /admin/post-settings

Looks like it's not being implemented. Content being displayed on the front page continue to be full nodes rather than 200 char teasers.

Whats gone haywire ?

Comments

4wding’s picture

The generated teaser text is saved in a cache, you need to go and edit the node again, submit it and then the new length should be shown.

The node module also attempts to break the text on a paragraph or sentence boundary, so this will also affect the final length.

tregeagle’s picture

I have exactly the same problem with all the (imported) nodes on my site.

Editing the posts individually then saving it does work, thanks 4wding.
I guess I'll need to dig a bit deeper to find a quicker way to update all the posts simultaneously.

4wding’s picture

Another way to flush the cache is to execute the database update script on your site:

http://yoursite.com/update.php

Do this when you are logged in as admin, and you will be asked if you want to perform the update. Usually nothing needs to be done, but the script will still empty all your cache data.

This should definitely be quicker for you :)

tregeagle’s picture

Thanks 4wding, I did try that but update.php did not resolve caching so maybe the cache was not the problem.
I've fixed up all the most popular posts, the rest can just be two-liners for now....

The posts were all imported using Steve's Wordpress to Drupal Conversion tool. I ran it under Linux which is completely untested... until now. So I wouldn't be surprised if that is where the problem lies. No-one but myself to blame :)

Although I should add that the above tool saved me heaps of work so a couple of little glitches are not a problem.

cheers

ruben

4wding’s picture

Thinking about it a little more, perhaps the node stores this in a different place than the main Drupal cache. I don't know too much about this area unfortunately.

You could try importing everything from Wordpress again with the new limit set ;) I'm guess that is a little too much work though.

At least you have things mostly working now.

superjacent’s picture

Firstly, thanks Ruben for your vote of confidence in my conversion program. When converting records from Wordpress to Drupal, if within Wordpress excerpts (teasers) are present then the excerpts are considered teasers and accordingly added to the teaser field within Drupal. The main body of the post is also added to the 'body' field of Drupal.

If excerpts are not used (or present) within Wordpress then what happens is that the body of the post is added to both the 'teaser' and 'body' fields of Drupal. Yes, they are duplicated.

Within Drupal, if the teaser length setting is not set that implies that the teaser is the entire post (article) which means the entire post (article) is stored in the 'teaser' and 'body' fields (duplicated).

I don't use the automatic teaser length setting (ie 200, 400 etc) as it's too rigid in use. It doesn't account for broken HTML tags, which will cause havoc for your application. I prefer the <!--break--> tag and purposely position it.

I'm not a PHP guru but from the structure of the Drupal 'node_revisions' table the front page (or main page or whatever it's called) the posts are populated from the 'teaser' field. When viewing a single post the information is populated from the 'body' field.

I can't comment on the caching issue but I don't think that is a factor regarding this issue.

___________________________

Steven Taylor
Melbourne, Australia.
http://superjacent.net/cms

Krotty’s picture

You can run this script to update all teasers on your site...

include "includes/bootstrap.inc";
include "includes/common.inc";
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$result = db_query("SELECT nid,body,teaser FROM node");

while ($node = db_fetch_object($result)) {
  $teaser = node_teaser($node->body);
  db_query("UPDATE node_revisions SET teaser = '%s' WHERE nid = %d", $teaser, $node->nid);
  $i++;
  echo $i;
}

tregeagle’s picture

That's great Krotty, thanks.
I've fixed up my teasers but that script could come in very useful...
... especially for my ongoing explorations into figuring out Drupal.

cheers
- ruben

alix’s picture

Krotty, this script seems to be just what I need (thank you!) but I'm having trouble running it. I get the error:

Fatal error: Cannot redeclare timer_start() (previously declared in /home/[me]/public_html/includes/bootstrap.inc:116) in /home/[me]/public_html/includes/bootstrap.inc on line 122

I am running Drupal 5.1 (haven't updated yet) and my host has PHP 5.2.4 installed. I'm not savvy enough yet to understand the cause -- could it be the PHP version?

Any ideas are welcome!

manefraim’s picture

It seems that you have added the above code to an existing Drupal page, rather than running the snippet in it's own file. Drupal includes 'bootstrap.inc' automatically before the include "includes/bootstrap.inc" line is called in the above snippet, hence the redeclaration of the function. Try making a new file ("update_teasers.php" or something) with the above snippet alone, and it should work.

szy’s picture

To make it work you should replace the line...

$result = db_query("SELECT nid,body,teaser FROM node");

... with this one:

$result = db_query("SELECT nid,body,teaser FROM node_revisions");

:]

Szy.

manerhabe’s picture

Thanks, this worked well for me. It seems like this should be apart of the standard maintenance tasks for Drupal's cron run.

gpk’s picture

Might become part of core + linked to cron, in due course.

gpk
----
www.alexoria.co.uk

pulpzebra’s picture

set the teaser length as 200 characters @ /admin/post-settings

In Drupal 5, with clean-urls enabled it's "/admin/content/node-settings".

beatnikdude’s picture

I updated teasers directly via SQL:
UPDATE node_revisions SET teaser = body WHERE vid = vid;
This does not trim posts according to preferences set at /admin/content/node-settings but it sets the teaser equal to the full body as if you set teaser length to unlimited on this page.

Leech’s picture

Thanks! That solved my problem!

OnlineWD™’s picture

Seems body is in node_revisions now rather than node as it was 2007.

<?php
include "includes/bootstrap.inc";
include "includes/common.inc";
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$result = db_query("SELECT nid,body,teaser FROM {node_revisions}");

while ($node = db_fetch_object($result)) {
  $teaser = node_teaser($node->body);
  db_query("UPDATE {node_revisions} SET teaser = '%s' WHERE nid = %d", $teaser, $node->nid);
  $i++;
  echo $i;
}
?>
bradweikel’s picture

This snippet is problematic, because each update writes over the teasers for ALL revisions of a node, not just the current revision. So it's a potential performance hit on sites with many revisions. Further, and more importantly, if the last revision in the SELECT isn't the published revision, the final teaser won't correspond to the published revision (which will happen, for instance, if you are using revisioning for an edit->approve workflow).

At the very least, it should update by vid instead of nid, but ideally it should probably also ignore all unpublished revisions.