I am using the views_slideshow module to display nodes on a slideshow and I created a build mode for this purpose. I love the concept, but I really need it to be able to display teaser text rather than the full body. Is there anyway to achieve this?

Comments

mstrelan’s picture

Anonymous’s picture

I actually tried to do this, but it turned out to be tricky. I will try it again, though! I think it's important to have access to the "snipped" body field of the node.

dboulet’s picture

I'm after this feature as well. I'll see if I can put a patch together.

dboulet’s picture

Status: Active » Needs review
StatusFileSize
new5.51 KB

This patch adds a setting to each build mode that allows you to choose how the body will be displayed.

The code in hook_theme_registry_alter() is maybe a little hackish, but otherwise this seems to work well. Please review.

dboulet’s picture

Status: Needs review » Needs work

Scratch that, regular teaser build mode is messed up in views.

dboulet’s picture

Status: Needs work » Needs review
StatusFileSize
new5.64 KB

This should work better I think.

Anonymous’s picture

Status: Needs review » Needs work

I'm not keen to replace a template preprocessor function from Views with the one from this module. Is there a way to do this without replacing template_preprocess_views_view_row_node()?

Given that we can have different template suggestions for each build mode, wouldn't it be better to store the teaser content in a different template variable and just print that out in the template instead of $content?

I will review this patch to determine if some of it can be used to accomplish at least this, but the rewriting of the theme registry this way isn't acceptable. The maintenance cost and risks are too high.

Anonymous’s picture

StatusFileSize
new1.41 KB

This doesn't exactly do what you are requesting, but it's what I've figured out so far.

node_view() unsets the teaser property on any node build that isn't a full normal build. This means there's no way to get the teaser later after running node_view without reloading the node. Fortunately, this is static cached, and we only need core node properties.

I wanted to get the filtered node body and teaser into my template, so I did this in the buildmodes_preprocess_node() function. It's generally a useful thing to do, but it doesn't affect the $content variable, and so you don't have fields and other node elements in there.

I think the right way to handle this problem is to implement hook_nodeapi for the 'alter' operation. This will allow you to re-set the body or teaser property and regenerate the content value for any node that's viewed... not just those viewed by buildmodes_node_view(). Then you can avoid altering the registry to replace the Views preprocessor function.

Anonymous’s picture

I just realized that you will need to add the "read more" link to the node links, because this is NOT added by core because it will believe the node is not a teaser.

dboulet’s picture

Not a big fan of swapping out the content in the template files, seems like an abuse of the theming system to me.

IMHO, having to create a template file for each new build mode defeats the purpose of the module.

Anonymous’s picture

I'm not going to commit a patch that replaces another contrib module's template_preprocess function with a different one. I'm not convinced this is necessary.

There are three other ways to attempt this:

  1. Create a different node row style plugin for Views that is used instead of the one Views uses.
  2. Attempt the hook_nodeapi($op = 'alter') method which would require no template changes at all.
  3. Rewrite the output of the node template's $content variable when the node's build mode needs a teaser.
dboulet’s picture

I agree, if we can accomplish this without hacking the theme registry as I did in my patch, that would definitely be preferred.

dboulet’s picture

After considering all the options presented here, I don't think that any of them are optimal—replacing the preprocess function is ugly, creating a new row style is inelegant and awkward for users, and all other suggestions would require building nodes twice, which is bad for performance.

I think that maybe what we need to do is submit a patch to the views module which allows custom build modes to display node teasers. That would make this much easier.

dboulet’s picture

I've created a new issue: #1023124: Allow custom node build modes to display teasers in node row style. We'll see what the maintainers think.

dboulet’s picture

I think that this feature is just not possible without ugly hacks. Since node bodies and their view modes are all hard coded in D6, it's just not a system that is flexible enough to allow this change to be easily made.

This is much easier in D7 where node bodies are proper fields.