I have the bookreview module. Suddenly it didn't make any teasers. After some trouble-shooting I found that the problem was that a certain teaser length was set in the code. Changing that lengt and the teasers started to work again. The thing is that I want teaser lenght to be indefinite, that is no lenght set. How do I write that in the code so that I get my teasers? I mean, it is easy to write 600, 800 etc but how do I write no lenght set so that it is understood by the computer?

Also. The teaser is set to

if ($node->synopsis) {
      $node->teaser = node_teaser($node->synopsis);
    }

I would like to have author in the teaser aswell. I tried to write like this;

 if ($node->synopsis) {
      $node->teaser = node_teaser($node->author, $node->synopsis);
    }

but that clearly didn't work. Any idea how I should write it instead?

Comments

he_who_shall_not_be_named’s picture

$node->teaser = $node->author . node_teaser($node->synopsis);
AstaC’s picture

for your trying. But no it didn't work. Instead of author I got the word "Array".

No solution for my first problem??

he_who_shall_not_be_named’s picture

$node->teaser = $node->author->author . node_teaser($node->synopsis);

I hope that this is good.

kuba.zygmunt’s picture

do you want to $node->teaser be the same as $node->body ?

(If I understood correctly, you don't want the teaser but the whole content from the node ( so it is $node->body)

  $node->teaser = $node->body

@vrencianz
$node->author->author
I think this is wrong. If the $node->author is array you cannot take the field like it is an object.

PS. what version of drupal do you use?

he_who_shall_not_be_named’s picture

For example, from the module:

  $i = 0;
  foreach ($node->authors as $author) {
    if ($author) {
      db_query("INSERT INTO {bookreview_authors} (nid, author, weight) VALUES (%d, '%s', %d)", $node->nid, $author, $i);
      $i++;
    }
  }

means that $node->authors exists:

So, $node->authors[0] is enough. Or:

  $authors_str = '';

  foreach ($node->authors as $author) {
    $authors_str .= $author . ' ';
  }

  $node->teaser = $authors_str . node_teaser($node->synopsis);

Sorry for my mistake. Please, tell me if something is wrong to close this subject.

AstaC’s picture

The last one worked. I tried the second one before and that one also gave the answer Array.

Thank you!
-------------

No, I didn't want the whole content (body) from bookreview as a teaser.

I want to set the amount of words for teaser to indefinite (no limit) in Drupal. But if I do that the bookreview module takes nothing with it since it wants a definite number in the code. As this:
if (variable_get('teaser_length', 2000
I can change 2000 to 1000 or 600 or whatever, but I do not know what to write for no limit at all.

he_who_shall_not_be_named’s picture

if teaser_length is set to 0 the node_teaser returns the whole passed content.

AstaC’s picture

Now it is exactly as I want it!
I don't really understand that variable about lenght because in this case you still only takes the synopsis of the book. Strange. But it doesn't matter. Now it works!
Thank's again.

Heine’s picture

The key to that question can be found on http://drupaldocs.org/node_teaser

  // If the size is zero, and there is no delimiter, the entire body is the teaser. 
  if ($size == 0 && $delimiter == 0) { 
    return $body; 
  }

BTW Wouldn't it be nicer/more flexible to tack the authornames on the teaser during display, instead of teaser generation?
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

AstaC’s picture

the difference? The one you mention in your BTW phrase. In this case it's just in a certain module And I want the author of the book to be seen in the teaser.
You're not talking about the author to the review itself?

(I am NOT a good programmer, can only make very easy changes).

Heine’s picture

No I was actually talking about the book authors. The problem when you store book authors in the teaser, only occurs much later, when you want to change the way these authors are displayed. But that might not be a very big deal.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

AstaC’s picture

Get what you mean.
But no - right now it doesn't seem to be a very big deal. If I ever get to be a better programmer perhaps I can fix that to if I want to change it :)

Heine’s picture

Just remember, if you ever get the need and you're a better programmer it's a 'simple' matter of regenerating the teasers ;-).
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

poloparis’s picture

i'm sorry, it may seem obvious to all but i still dont see how we change the $size

still in : http://drupaldocs.org/node_teaser
in the preceding line: $size = variable_get('teaser_length', 600);

where do we call that variable_get function or how do we change the value 600 to any other value ?

Heine’s picture

You can do that in via the admin interface.

variable_get fetches the variable teaser_length from the database (the one you set via the admin interface). When the variable hasn't been set it gives you the number 600. So if you've set it to 0, node_teaser returns the entire body.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

poloparis’s picture

Thanks for that Heine. i still got so much to learn about Drupal, but working hard at it.

i see where to set it : admin > settings > posts - i had overlooked it before cause i thought that was only for forum posts, not node content in general.

he_who_shall_not_be_named’s picture

You're wellcome