Needs work
Project:
Build modes
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
8 Oct 2010 at 04:26 UTC
Updated:
7 Feb 2011 at 00:30 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
mstrelan commentedFor api reference see http://drupal.org/node/697320#hook_content_build_modes
Comment #2
Anonymous (not verified) commentedI 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.
Comment #3
dboulet commentedI'm after this feature as well. I'll see if I can put a patch together.
Comment #4
dboulet commentedThis 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.
Comment #5
dboulet commentedScratch that, regular teaser build mode is messed up in views.
Comment #6
dboulet commentedThis should work better I think.
Comment #7
Anonymous (not verified) commentedI'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.
Comment #8
Anonymous (not verified) commentedThis 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.
Comment #9
Anonymous (not verified) commentedI 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.
Comment #10
dboulet commentedNot 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.
Comment #11
Anonymous (not verified) commentedI'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:
Comment #12
dboulet commentedI agree, if we can accomplish this without hacking the theme registry as I did in my patch, that would definitely be preferred.
Comment #13
dboulet commentedAfter 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.
Comment #14
dboulet commentedI'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.
Comment #15
dboulet commentedI 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.