I have code that uses node_teaser() to get a node's teaser (duh).
However this appears to only get the default teaser length, i.e. doesnt work with your module.

As the maintainer of this module, how would you suggest I integrate my module with yours? (i.e. get the correct teaser length).
I am assuming something like

if module_exists(teaserbytype) {
  $node= node_load($nid);
  $length = variable_get('teaser_length_' . $node['type']);
  ...

But I thought I'd get your input, maybe youve your own api or something.
Thanks!

Comments

Mike_Waters’s picture

Status: Active » Closed (fixed)

OK, apparently for D6 there is a third parameter to node_teaser() (which I only discovered after examining your module ;).
This is going to be easier than I thought, sorry for the spam.

joachim’s picture

You probably don't even need the module exists -- just check the variable and default to the global one.
Though on the other hand, a user might disable teaserbytype and then they'd expect the teaser_length_TYPE variable to be ignored.
So the way you suggest would be the way to do it, pretty much :)

Do $size = variable_get('teaser_length_'. $node->type, NULL);
and then pass $size to node_teaser. If the var isn't set, then $size is NULL, and then node_teaser uses the site-wide setting.

joachim’s picture

Heh comment collision :)

And yes, this module was a lot easier to write on D6 than on D5!